Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSD - Allowing XML Attributes inside an ordinary Element

Status
Not open for further replies.

thoppy

Programmer
Aug 21, 2009
2
GB
I'm trying to allow the following within an XML file:

[tt]<Quantity uom="ea">4</Quantity>[/tt]

I have tried to support this within the XSD schema, as follows:

[tt]<xsd:element name="Quantity" type="xsd:integer">
<xsd:complexType>
<xsd:attribute name="uom" type="xsd:string" />
</xsd:complexType>
</xsd:element>[/tt]


However, my mapping program (Altova MapForce) rejects the XSD, saying that: "The 'type' attribute and an anonymous type definition are mutually exclusive for element declaration 'Quantity'."

I'm sure this must be simple and I must be doing the wrong Google searches, because I can't find the answer, so I do apologise.

What am I doing wrong in the XSD and how should this be defined instead?
 
[tt]<xsd:element name="Quantity">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:integer">
<xsd:attribute name="uom" type="xsd:string"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>[/tt]
 
Thank you tsuji,
Your help is much appreciated!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top