Xsd.exe使用SubstitutionGroup / anytype生成不可用的代码

时间:2013-04-19 05:19:31

标签: c# xml xsd xsd.exe xbrl

确定。我正在尝试从以下位置生成c#类: http://www.xbrl.org/2003/xbrl-instance-2003-12-31.xsd (基本上是xbrl架构)。

我遇到了元组和项目的问题。

这是xsd的样子:

  <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>

序列的生成属性如下所示:

[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;
  }
}

基本上不生成元组和项抽象基类。因此,即使其他模式具有substitutiongroup =“tuple”,我也无法将其放入。(我可以,但它不会序列化)。

1 个答案:

答案 0 :(得分:0)

Xsd.exe无法处理W3C XSD标准中的一些更复杂的构造。因此,您可能需要查看第三方数据绑定产品。

可在此处找到产品清单(但它们都有点过时)

Liquid XML Data Binder我们取得了不错的成绩。