[
Lists Home |
Date Index |
Thread Index
]
I have a question on XML-Schema:
Is it possible to have:
<xs:element name="vehicle">
<xs:complexType>
<xs:attribute name="plateNumber" type="xs:integer"/>
</xs:complexType>
</xs:element>
<xs:element name="state">
<xs:complexType>
<xs:sequence>
<xs:element name="code" type="xs:string"/>
<xs:element ref="vehicle" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:key name="reg">
<xs:selector xpath=".//vehicle"/>
<xs:field xpath="@plateNumber"/>
</xs:key>
</xs:element>
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="car" maxOccurs="unbounded"/>
<xs:complexType>
<xs:attribute name="regPlate" type="xs:integer"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:keyRef name="carRef" refer="reg">
<xs:selector xpath=".//car"/>
<xs:field xpath=@regPlate"/>
</xs:keyRef>
</xs:element>
Is the above a correct schema. And in that case can I have a document like
<root>
<state>
<code>CA</code>
<vehicle plateNumber="1"/>
<vehicle plateNumber="2"/>
</state>
<state>
<code>MA</code>
<vehicle plateNumber="1"/>
</state>
<person>
<car regPlate="1"/>
</person>
<person>
<car regPlate="2"/>
</person>
</root>
is this a valid instance for that schema??
thanks, murali.
|