Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xsd.exe generating unusable code with SubstitutionGroup/anytype

Ok. I'm trying to generate c# classes from: http://www.xbrl.org/2003/xbrl-instance-2003-12-31.xsd (The xbrl schema basically).

I am having problem with the tuple and the item.

Here's what the xsd looks like:

  <element name="tuple" type="anyType" abstract="true">
    <annotation>
      <documentation>
      Abstract tuple element used as head of tuple substitution group
      </documentation>
    </annotation>
  </element>

  <element name="xbrl">
    <annotation>
      <documentation>
      XBRL instance root element.
      </documentation>
    </annotation>
    <complexType>
      <sequence>
        <element ref="link:schemaRef" minOccurs="1" maxOccurs="unbounded" />
        <element ref="link:linkbaseRef" minOccurs="0" maxOccurs="unbounded" />
        <element ref="link:roleRef" minOccurs="0" maxOccurs="unbounded" />
        <element ref="link:arcroleRef" minOccurs="0" maxOccurs="unbounded" />
        <choice minOccurs="0" maxOccurs="unbounded">
          <element ref="xbrli:item"/>
          <element ref="xbrli:tuple"/>
          <element ref="xbrli:context"/>
          <element ref="xbrli:unit"/>
          <element ref="link:footnoteLink"/>
        </choice>
      </sequence>
      <attribute name="id" type="ID" use="optional" />
      <anyAttribute namespace="http://www.w3.org/XML/1998/namespace"
                    processContents="lax" />
    </complexType>
  </element>

And the generated property for the sequence looks like this:

[System.Xml.Serialization.XmlElementAttribute("context", typeof(context))]
[System.Xml.Serialization.XmlElementAttribute("item", typeof(object))]
[System.Xml.Serialization.XmlElementAttribute("tuple", typeof(object))]
[System.Xml.Serialization.XmlElementAttribute("unit", typeof(unit))]
[System.Xml.Serialization.XmlElementAttribute("footnoteLink", typeof(footnoteLink),
                             Namespace="http://www.xbrl.org/2003/linkbase")]
public object[] Items {
  get {
    return this.itemsField;
  }
  set {
    this.itemsField = value;
  }
}

Basically the tuple and item abstract base class are not generated. So even when other schema has substitutiongroup="tuple" i can't put it in. (Well I can, but it won't serialize).

like image 310
Sleeper Smith Avatar asked Nov 12 '22 06:11

Sleeper Smith


1 Answers

Xsd.exe does not cope with some of the more complex constructs within the W3C XSD standard. So your probably going to have to look to a third party data binding product.

A list of products can be found here (but they are both a bit out of date)

  • http://www.rpbourret.com/xml/XMLDataBinding.htm#designtime
  • http://xmldatabinding.org/

We've had good results with Liquid XML Data Binder.

like image 126
Sprotty Avatar answered Nov 15 '22 11:11

Sprotty