m Matt
on

 

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:

<code>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'.
  - Group 'MetaDataVersionPreIncludeElementExtension' from targetNamespace='http://www.cdisc.org/ns/odm/v1.2' has invalid definition: Circular group reference.</code>

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?
http://connect.microsoft.com/VisualStudio/feedback/details/637855/xsd-exe-fails-to-handle-circular-group-references

Thanks,
Matt

Forums: Troubleshooting and Problems

m Matt
on August 2, 2012

I edited the define-extension.xsd and validator-extension.xsd files to comment out the MetaDataVersionPreIncludeElementExtension element in the MetaDataVersionPreIncludeElementExtension sequence. 

<code>
<xs:group name="MetaDataVersionPreIncludeElementExtension">
    <xs:sequence>
        <!-- Commented out to allow generation with XSD.exe - causes circular reference error -->
        <!--<xs:group ref="MetaDataVersionPreIncludeElementExtension"/>-->
        <xs:element ref="def:AnnotatedCRF" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="def:SupplementalDoc" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="def:leaf" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="def:ComputationMethod" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="def:ValueListDef" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
</xs:group>
<code>

And it no longer said it was a circular reference for MetaDataVersionPreIncludeElementExtension .  But it did give more circular references:

  • MetaDataVersionElementExtension (validator only)
  • ItemGroupDefElementExtension (define & validator)
  • ItemDefElementExtension (define & validator)

So I modified the XSDs the same way and it generated the C# file for me.  But there are still some schema validation warnings it presents that I don't understand.  They are a result of me commenting out the elements in the sequence.

<code>
Schema validation warning: Invalid particle derivation by restriction. Line 29, position 5.
Schema validation warning: Invalid particle derivation by restriction. Line 95, position 5.
Schema validation warning: Invalid particle derivation by restriction. Line 53, position 5.
Schema validation warning: Invalid particle derivation by restriction. Line 77, position 6.
</code>

Any ideas on how to fix them?

Thanks,
Matt

a Anthony
on August 4, 2012

Dear Matt:

No, I haven't tried that either. However, you may find this useful, especially what it says re: MSXML.

http://www.cdisc.org/stuff/contentmgr/files/0/464923b10ea16b477151fcaa9f465166/misc/definereport_v1_0.pdf

m Matt
on August 17, 2012

I think that references the validation of XML files based on the XSD, not validation of the XSD itself.

I found this indicating that XSD.exe doesn't support redefine tags:
http://msdn.microsoft.com/en-us/library/xsayb845%28v=vs.90%29.aspx
(Found from this page: http://social.msdn.microsoft.com/Forums/sr-sp-latn/wcf/thread/ce989d78-357d-47c3-b801-9d4de6d21d15)

Any ideas on how to modify the XSD files to get around this?

m Matt
on August 17, 2012

I think I figured it out.  I did some commenting out and it generates w/o any errors or warnings.

I basically commented out:

  1. the redefine elements (but not their child elements) in the define-extension.xsd and validator-extension.xsd
  2. the original definitions in the ODM1-2-1-foundation.xsd that were extended
  3. the duplicate redefines in validator-extension.xsd that matched the ones in define-extension.xsd
  4. the redefines in the define-extension.xsd that were further extended in validator-extension.xsd
  5. the child elements in the redefines that caused the circular definition error

 

Want a demo?

Let’s Talk.

We're eager to share and ready to listen.

Cookie Policy

Pinnacle 21 uses cookies to make our site easier for you to use. By continuing to use this website, you agree to our use of cookies. For more info visit our Privacy Policy.