Hi,
Since the project uses Java, I’m assuming no one has done this, but I’d thought I check anyhow.
I was trying to generate C# classes based on the validator1-0-0.xsd schema (http://svn.opencdisc.org/validator/trunk/resources/schema) in order to read the config files for SEND. I was hoping to be able to use the OpenCDISC SEND configuration files since they pretty much layout the entire SEND format in a way that I can work with programmatically.
I copied all the xsd files from the SVN resources folder as well as the ODM v1.2.1 schema files into a folder:
- define1-0-0.xsd
- define-extension.xsd
- define-ns.xsd
- ODM1-2-1.xsd
- ODM1-2-1-foundation.xsd
- validator1-0-0.xsd
- validator-extension.xsd
- validator.ns.xsd
- xml.xsd
- xmldsig-core-schema.xsd
I then tried using the Microsoft Visual Studio XSD tool to generate the C# classes with the following command line:
<path to xsd.exe> /c /l:CS /n:OpenCDISC.Validator validator1-0-0.xsd
The path to xsd.exe for me is: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\xsd.exe
Unfortunately the XSD tool had problems resolving references over the web, so I needed to modify the files to point to the local XSD instead of the URL. To do this I removed everything but the XSD filename from the XSD files in the schemaLocation attribute of the xs:import and xs:redefine elements.
I also had to add the xmldsig-core-schema.xsd and define-ns.xsd to my command line (as it appeared to still had issues resolving nested includes):
<path to xsd.exe> /c /l:CS /n:OpenCDISC.Validator xmldsig-core-schema.xsd define-ns.xsd validator-ns.xsd validator1-0-0.xsd
With that change to the command line, these were the only issues:
Schema validation warning: The ‘http://www.w3.org/1999/xlink:href’ attribute is not declared. Line 63, position 9.
Warning: Schema could not be validated. Class generation may fail or may produce incorrect results.
Error: Error generating classes for schema ‘xmldsig-core-schema_define-ns_validator-ns_validator1-0-0’.
Unfortunately due to the Error, it’s unable to generate the C# code.
Does anyone have any suggestions or patches to resolve the circular group reference of ODM’s MetaDataVersionPreIncludeElementExtension? I was able to generate ODM 1.2.1 C# classes using the XSD tool just fine, so I’m guessing the issue is in the validation XSDs. It’s used in:
- validator-extension.xsd lines 28 and 30
- define-extension.xsd lines 28 and 30
UPDATE (2012-08-02): I found this on Microsoft’s bug reporting site. Apparently circular group references are not allowed according to the W3C’s specs for Model Group Validation. So the XSD tool doesn’t support them. So I guess the question is how can I modify the XSD(s) to be compliant and still usable?
Thanks,
Matt