tags:

views:

52

answers:

2

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 Object type in java, is it possible to create like in XSD.

Edit: At complex type level is it possible.

A: 

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

Robert Christie
+1  A: 

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)

Andreas_D
Thanks. At complex type level is it possible
GK