EDN Admin
Well-known member
Hi All,
I have a XML for which i have created a XSD. I have a requirement where i need to be able to specify conditions in using attributes. Let me explain with an example.
This is a small part of my XSD
<xs:element name="action" maxOccurs="1
<xs:complexType>
<xs:attribute name="name" type="Action" use="required" />
<xs:attribute name="var" type="xs:string" use="optional" />
<xs:attribute name="value" type="xs:string" use="optional" />
<xs:attribute name="varvar" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
Here i have 4 attributes for element Action. The first attribute name is required. I have made the other attributes optional. Actually what i want to achieve is, i should be able to use only one of the remaining attributes i.e., var|value|varvar.
If i try to write an XML using the above schema i can write.
<action name="set" value="Transzip" var="m_ProductName" varvar="m_Product </action>
It will allow me to specify all the four attributes. I want it to be such a way that if i use attribute value it should not allow me to specify var or varvar. My XML element action should have only 2 attributes name and (var or value or varvar).
How do i specify this in the XSD?
I hope i have made my problem clear. Any help is highly appreciated.
Thanks,
Bharath
View the full article
I have a XML for which i have created a XSD. I have a requirement where i need to be able to specify conditions in using attributes. Let me explain with an example.
This is a small part of my XSD
<xs:element name="action" maxOccurs="1
<xs:complexType>
<xs:attribute name="name" type="Action" use="required" />
<xs:attribute name="var" type="xs:string" use="optional" />
<xs:attribute name="value" type="xs:string" use="optional" />
<xs:attribute name="varvar" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
Here i have 4 attributes for element Action. The first attribute name is required. I have made the other attributes optional. Actually what i want to achieve is, i should be able to use only one of the remaining attributes i.e., var|value|varvar.
If i try to write an XML using the above schema i can write.
<action name="set" value="Transzip" var="m_ProductName" varvar="m_Product </action>
It will allow me to specify all the four attributes. I want it to be such a way that if i use attribute value it should not allow me to specify var or varvar. My XML element action should have only 2 attributes name and (var or value or varvar).
How do i specify this in the XSD?
I hope i have made my problem clear. Any help is highly appreciated.
Thanks,
Bharath
View the full article