1

According to using xsd.exe to generate c# files, getting error and warnings I've downloaded all 115 XSD files needed for GML (Geography Markup Language) definition including all referenced files, changed their "schemaLocation" attributes in "import" and "include" elements to correct local paths and tried to generate a C# class using the "xsd.exe" utility:

xsd.exe /classes xsd\online\httpschemasopengisnetgml311base\basicTypes.xsd xsd\online\httpschemasopengisnetgml311base\coordinateOperations.xsd ...

And I keep getting tons of errors, most commonly this kind:

Schema validation warning: The global element 'http://www.opengis.net/gml:_CoordinateOperation' has already been declared. Line 24, position 3.

I've searched through the web but found no solution. I just suspect that there could be some attributes with same names and the "xsd.exe" utility cannot manage this but I am not sure if this can happen.

1 Answers1

0

I don't think you need to list all the files as parameters unless the schemaLocation attributes aren't correct (although personally I've never had that situation - I would correct that first). So, if you are aware of how the schemas are structured and confident in the schemaLocation attrubutes you should only need to specify those 'top level' schemas which are not referenced by other schemas.

spodger
  • 1,668
  • 1
  • 12
  • 16
  • 1
    Unfortunately the utility forces me to mention all the referenced files, although all path are correct. When I don't do it, many other errors appear. I was once successfull when making C# classes as I described in my question, just with distinctively less number of XSD files (and they were not part of GML definition). –  Nov 02 '17 at 14:53
  • Are your "local paths" the same as the paths used on the command line, i.e. ``? – spodger Nov 02 '17 at 15:56
  • No. They are relative, but not related to folder where I have got "xsd.exe", but related to their own folder. I mean: it is a correct relative path, for example: ..\online\httpschemasopengisnetgml311base\b‌​asicTypes.xsd . –  Nov 02 '17 at 16:02
  • They need to match, I believe, otherwise Xsd.exe will regard a file you have specified on the command line as different from one included via schemaLocation. So, you need to run Xsd from a location where the top level schemas are and the folder structure underneath must match the schemaLocation paths. If this is the case you shouldn't need to specify any schemas other than top level ones. – spodger Nov 02 '17 at 16:09
  • Thanks a lot for your help, but I am sure they don't need to match. I successfully created a C# classes a few minutes ago using different paths in command and in XSD file (in XSD: schemaLocation="..\online\httpschemasopengisnetgml311base\gml.xsd", in command: xsd.exe /classes xsd\objekty_bez_geometrie\aktivni_zarizeni_elektricke_site.xsd xsd\common\atributy.xsd xsd\common\common.xsd). The problem must be somewhere else. –  Nov 02 '17 at 17:11
  • Sorry, I'm confused by your last post. You have quoted `schemaLocation="..\online\httpschemasopengisnetgml311base\gm‌​l.xsd` but not referenced that schema in your command line. – spodger Nov 03 '17 at 08:43
  • Of course, there is a possibility that there is a clash within the schemas. Have you checked, for instance, whether `http://www.opengis.net/gml:_CoordinateOperation` has actually been declared in more than one schema? – spodger Nov 03 '17 at 08:49
  • Sorry, to give better example: in XSD: schemaLocation="..\online\httpschemasopengisnetgml311base\gm‌​l.xsd", in command: xsd.exe /classes xsd\online\httpschemasopengisnetgml311base\gm‌​l.xsd ... –  Nov 03 '17 at 09:28