| 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. |