Tuesday, 17 February 2015

Validation attribute in XSD



I have a problem in a XSD,I need to validate an XML in XSD, but I have trouble to declare the attribute.


The attribute is:



<xs:attribute name='currency' type='xs:string'/>


Code in XML:



<price currency="€">30,65</price>


Code XSD:



<xs:element type="xs:string" name="information"/>
<xs:element type="xs:string" name="data"/>
<xs:element type="complexPrice" name="price"/>
<xs:complexType name="complexPrice">
<xs:attribute name='currency' type='xs:string'/>
</xs:complexType>


This is error:


S4s-elt-must-match.1: The Content Of 'price' Must Match (annotation?, (simpleType | ComplexType)?, (unique | Key | Keyref))). A Problem Was Found Starting At: Attribute.*


Thanks for the help.


No comments:

Post a Comment