使用SCD从complexType中选择xsd:element

时间:2016-08-26 09:02:25

标签: xml xsd jaxb scd

我正在尝试使用SCD选择complexType的子元素,但SCD选择complexType。 SCD文档很差,我不明白,如何正确选择子元素。 这是XSD片段:

<xsd:complexType name="request">
      <xsd:sequence>
          <xsd:element form="unqualified"
                        maxOccurs="unbounded" minOccurs="0" name="partner"
                        type="ns1:Partner" />
          <xsd:element form="unqualified"
                        maxOccurs="unbounded" minOccurs="0" name="foo"
                        type="xsd:anyType" />
          <xsd:element form="unqualified"
                        maxOccurs="unbounded" minOccurs="0" name="foo2"
                        type="xsd:anyType" />    
      </xsd:sequence>
</xsd:complexType>

我写了以下绑定:

<bindings scd="x-schema::tns" xmlns:tns="http:/mynamespace.com/xsd">
    <schemaBindings>
       <package name="com.otherpackage.xsd" />
    </schemaBindings>
    <bindings scd="/~tns:request:schemaElement:foo">
           <class ref="com.othernamespace.OhterFoo" />
    </bindings>
    <bindings scd="/~tns:request:schemaElement:foo2">
           <class ref="com.othernamespace.OhterFoo" />
    </bindings>
</bindings>

我也尝试过以下绑定,但是使用这个绑定它甚至都不会生成源代码。

<bindings scd="x-schema::tns" xmlns:tns="http:/mynamespace.com/xsd">
        <schemaBindings>
           <package name="com.otherpackage.xsd" />
        </schemaBindings>
        <bindings scd="/type::tns:request/model:sequence/schemaElement::tns:foo">
               <class ref="com.othernamespace.OhterFoo" />
        </bindings>
        <bindings scd="/type::tns:request/model:sequence/schemaElement::tns:foo2">
               <class ref="com.othernamespace.OhterFoo" />
        </bindings>
    </bindings>

1 个答案:

答案 0 :(得分:0)

使用此example

中提供的model::sequence加倍::