FAQ: Difference between revisions

From DATA4PT WIKI
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:


'''Question:'''
'''Question''': How can you create C# classes from the NeTEx XSD?


'''Answer:'''
'''Answer''': It is possible to create C# classes in different ways.


'''Question''': How can you create C# classes from the NeTEx XSD?
There are many tools out there, but for instance, you could use the '''Microsoft xsd.exe''' tool or the '''mganss/XMLSchemaClassGenerator''' tool available on Github [https://github.com/mganss/XmlSchemaClassGenerator]


'''Answer''': The Data4PT project has developed some separate XSD-files that can be used to generate C# code.
Currently there are some issues if you try to use the official NeTEx XSD as a starting point with either of these tools.  


However, the above mentioned tools work fine if you use them together with another set of XSD-files available from Data4PT. The file set is designed to be compatible with the official NeTEx XSD. A limitation is that does not cover all use cases.


'''Question:'''
If you wish to try out this reduced XSD, you can download it at https://data4pt.org/NeTEx/GraphicKit/XSD_reduced.zip


'''Answer:'''
The work steps if you are using the Microsoft tool are:
 
# Get the zipped XSD. Extract the ZIP to a folder.
# Make sure that you have a recent version of the xsd.exe. It is part of the .NET Framework Developer Pack and can be downloaded from https://dotnet.microsoft.com/download/dotnet-framework
# Install the developer pack. The xsd.exe will be placed in a folder with a path similar to ''C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools''
# Open a command prompt in the same folder as where the NeTEx_publication_reduced-NoConstraint.xsd resides.
# Execute the following command (you may have to adapt the path to xsd.exe): ''"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\xsd.exe" /c /language:C# gml_combo_v3_2_1_simplified.xsd NeTEx_publication_reduced-NoConstraint.xsd''
 
The work steps if you are using the MGANSS tool are:
 
# Get the zipped XSD. Extract the ZIP to a folder with a path such as ''C:\tmp\codegen_M''.
# Download the binary from https://github.com/mganss/XmlSchemaClassGenerator/releases and expand it to a separate folder.
# Open a command prompt in the same folder as where the NeTEx_publication_reduced-NoConstraint.xsd resides.
# Execute the following command (you may have to adapt the path to the exe): ''C:\tmp\codegen_M\XmlSchemaClassGenerator.Console.exe NeTEx_publication_reduced-NoConstraint.xsd  -n <nowiki>http://www.opengis.net/gml/3.2=gml</nowiki> -v''

Revision as of 12:05, 1 February 2021

Question: How can you create C# classes from the NeTEx XSD?

Answer: It is possible to create C# classes in different ways.

There are many tools out there, but for instance, you could use the Microsoft xsd.exe tool or the mganss/XMLSchemaClassGenerator tool available on Github [1]

Currently there are some issues if you try to use the official NeTEx XSD as a starting point with either of these tools.

However, the above mentioned tools work fine if you use them together with another set of XSD-files available from Data4PT. The file set is designed to be compatible with the official NeTEx XSD. A limitation is that does not cover all use cases.

If you wish to try out this reduced XSD, you can download it at https://data4pt.org/NeTEx/GraphicKit/XSD_reduced.zip

The work steps if you are using the Microsoft tool are:

  1. Get the zipped XSD. Extract the ZIP to a folder.
  2. Make sure that you have a recent version of the xsd.exe. It is part of the .NET Framework Developer Pack and can be downloaded from https://dotnet.microsoft.com/download/dotnet-framework
  3. Install the developer pack. The xsd.exe will be placed in a folder with a path similar to C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools
  4. Open a command prompt in the same folder as where the NeTEx_publication_reduced-NoConstraint.xsd resides.
  5. Execute the following command (you may have to adapt the path to xsd.exe): "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\xsd.exe" /c /language:C# gml_combo_v3_2_1_simplified.xsd NeTEx_publication_reduced-NoConstraint.xsd

The work steps if you are using the MGANSS tool are:

  1. Get the zipped XSD. Extract the ZIP to a folder with a path such as C:\tmp\codegen_M.
  2. Download the binary from https://github.com/mganss/XmlSchemaClassGenerator/releases and expand it to a separate folder.
  3. Open a command prompt in the same folder as where the NeTEx_publication_reduced-NoConstraint.xsd resides.
  4. Execute the following command (you may have to adapt the path to the exe): C:\tmp\codegen_M\XmlSchemaClassGenerator.Console.exe NeTEx_publication_reduced-NoConstraint.xsd -n http://www.opengis.net/gml/3.2=gml -v