How to create a generic XSD type

后端 未结 2 1320
抹茶落季
抹茶落季 2021-01-15 00:58

I have a java application where i can map a XSD type to another with same type. Now i have requirement to have one anyType xsd to which i can map any type. Like as we have O

相关标签:
2条回答
  • 2021-01-15 01:29

    Yes, it's possible. The type is xsd:anyType. Here's an example:

    <xsd:element name="anything" type="xsd:anyType"/>
    

    (Taken from the primer)

    Here's a more complex example:

    <xsd:complexType>
      <xsd:complexContent>
        <xsd:restriction base="xsd:anyType">
          <xsd:attribute name="currency" type="xsd:string"/>
          <xsd:attribute name="value"    type="xsd:decimal"/>
        </xsd:restriction>
      </xsd:complexContent>
    </xsd:complexType>
    

    (From the primer as well - it's worth looking at at it)

    0 讨论(0)
  • 2021-01-15 01:35

    You could use the xs:any element - this allows you to have a section of you schema that can contain any arbitrary XML.

    0 讨论(0)
提交回复
热议问题