tags:

views:

10

answers:

1

Hi,

I need to define an attribute called "DataValue" of an element "MyData". But the requirement is that the type of "DataValue" can change dynamically i.e., the data value could be string in one instance and in other instance it could be int or bool. It could be any of the xml data type. For example in one instance the xml could look like this where data value is xs:string

<MyData DataName = "Message" DataValue = "Hello" />

In other instance the data value could be xs:integer and xml will look like this

<MyData DataName = "Message" DataValue = "123" />

Please help me write the correct xsd for this.

 <xs:complexType name="MyData">
    <xs:attribute name="DataName" type="xs:string" use="required" />
    <xs:attribute name="DataValue" **type="????????"**  use="required" />     
</xs:complexType>

If the type of an attribute can change dynamically, how do i indicate that in XSD? Is there a way i can specify that the type of the attribute could be any of the xml datatypes and not fixed? Please help me.

+2  A: 

You can use xsd:anyType for that.

Jim Brissom