I am trying to create a Xml schema for a xml file that looks like following
<attributes>
<attribute name="article_artextref">123213213</attribute>
<attribute name="ProviderID">ABC</attribute>
</attributes>
What I am trying to accomplish is check if an attribute named "article_artextref" exist and make sure the lenght of its value is larger than 1. I dont want to validate the lenght of attribute name "ProviderID" and the length for provider ID can be 0.
Please help.
I am adding the xml schema I have which so far checks the length for both of the elements.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="ST_attribute">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="attributes">
<xs:complexType>
<xs:sequence>
<xs:element ref="attribute" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="attribute">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="ST_attribute">
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="ProviderID"/>
<xs:enumeration value="article_artextref"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>