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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mixing Content Type and Attributes 1

Status
Not open for further replies.

parmy

Programmer
Apr 23, 2007
1
GB
I'm not sure if this is possible but I would like to allow the following:

<boolean id="x">true</boolean>

The closest I can get to this using an XSD Schema is the following:

<boolean id="x">
<value>true</value>
</boolean>

The problem appears to be with specifying the element type and allowing attributes which requires a "complexType".

I have tried the following:

<xs:element name="boolean" type="xs:boolean">
<xs:complexType>
<xs:attribute name="id" type="xs:ID" use="required"></xs:attribute>
</xs:complexType>
</xs:element>

However I get the following error:

Element 'boolean' had both a 'type' attribute and a "annoynous type" child. Only one of these is allowed for an element.

I have tried various approaches using restrictions, extentsions, complexTypes and simpleTypes, however I can't find a solution that works.

As I mentioned earlier the closest I can get is using:

<xs:element name="boolean">
<xs:complexType>
<xs:all>
<xs:element name="value" minOccurs="1" maxOccurs="1" type="xs:boolean"/>
</xs:all>
<xs:attribute name="id" type="xs:ID" use="required"/>
</xs:complexType>
</xs:element>

However I find the requirement to have the boolean value stored in a child node (in this instance "values"), superfluous.

Any suggestions would be appreciated.

Thanks in advance

Parmy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top