XSD - Howto specify element whose name is unknown

S

slimzhao

<title>
<A ID="ID_1"/>
<B ID="ID_2"/>
<SomeThingElse ID="ID_1000"/>
</title>


What I want to do is to write a schema for <title>'s children, which
element type is restricted to <xs:attribute name="ID" type="ID">, but
it's name is variable.

Thanks any way.
 
J

Jens M. Felderhoff

<title>
<A ID="ID_1"/>
<B ID="ID_2"/>
<SomeThingElse ID="ID_1000"/>
</title>


What I want to do is to write a schema for <title>'s children, which
element type is restricted to <xs:attribute name="ID" type="ID">, but
it's name is variable.

You might consider using substitutionGroup, e.g.

<xs:element name="id-elem" abstract="true">
<xs:complexType>
<xs:attribute name="ID" type="ID"/>
</xs:complexType>
</xs:element>

<xs:element name="A" substitutionGroup="id-elem">
....
</xs:element>

<xs:element name="B" substitutionGroup="id-elem">
....
</xs:element>

<xs:element name="SomeThingElse" substitutionGroup="id-elem">
....
</xs:element>

<xs:element name="title">
<xs:complexType>
<xs:element ref="id-elem" maxOccurs="unbounded"/>
</xs:complexType>
</xs:element>

Cheers

Jens
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top