Connecting Tech Pros Worldwide Forums | Help | Site Map

XSD question (same attributes, different elements...)

Gooseman
Guest
 
Posts: n/a
#1: Jul 20 '05
Hi

Just getting into XSD and have some questions:

If I have several different elements that all have identical
attibutes, what is the best way of conveying that in the XSD?

Is there a way of defining that an attribute must be either xs:ID OR a
set of predefined lables (ie something like xs:ID | "specific_lable_1"
| "specific_lable_2" ?

The XSD schema I am writing is fully defined, yet some of the
attributes for the various elements are yet to be implemented. What's
the best way of adding a "not yet implemented" flag to these
attributes?

Thanks!
DFN-CIS NetNews Service
Guest
 
Posts: n/a
#2: Jul 20 '05

re: XSD question (same attributes, different elements...)


On 22/01/2004, around 11:24, Gooseman wrote:
G> Hi

G> Just getting into XSD and have some questions:

G> If I have several different elements that all have identical
G> attibutes, what is the best way of conveying that in the XSD?
You want to look up 'attribute groups' ...

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element ref="element1"/>
</xs:sequence>
<xs:attributeGroup ref="ag1"/>
</xs:complexType>
</xs:element>
<xs:element name="element1" type="xs:string"/>
<xs:attribute name="att1" type="xs:string"/>
<xs:attribute name="att2" type="xs:string"/>
<xs:attribute name="att3" type="xs:string"/>
<xs:attributeGroup name="ag1">
<xs:attribute ref="att1" use="required"/>
<xs:attribute ref="att2" use="optional"/>
</xs:attributeGroup>
<xs:attributeGroup name="ag2">
<xs:attribute ref="att2" use="required"/>
<xs:attribute ref="att3" use="required"/>
</xs:attributeGroup>
</xs:schema>

--
Stuart
Friends may come and go, but enemies accumulate.

Closed Thread