Reputation: 2618
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.
Upvotes: 0
Views: 363
Reputation: 163587
You want to define a "complex type with simple content", something like this:
<xs:element name="price">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:decimal">
<xs:attribute name="currency" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
Upvotes: 1