Special restriction on IDREF

L

Luigi

Hello!

I'm writing a schema where an element has got a reference to another
element via IDREF. The problem is that I would restrict the possible
references to the sole elements of a specific type, or, in other
words, to those element with a specific tag name. For instance:

<xs:element name="A">
<xs:complexType>
<xs:attribute name="id" type="xs:ID"/>
</xs:complexType>
</xs:element>

<xs:element name="B">
<xs:complexType>
<xs:attribute name="id" type="xs:ID"/>
</xs:complexType>
</xs:element>

<xs:element name="C">
<xs:complexType>
<xs:attribute name="idref" type="xs:IDREF"/>
</xs:complexType>
</xs:element>

I want that C elements could have references only to A elements. Is it
possible?

Thank you in advance.
 
P

Pavel Lepin

Luigi said:
I'm writing a schema where an element has got a reference
to another element via IDREF. The problem is that I would
restrict the possible references to the sole elements of a
specific type, or, in other words, to those element with a
specific tag name.

I want that C elements could have references only to A
elements. Is it possible?

As far as I can tell, it's not possible. Check on
application side. XML Schema is not designed to define
arbitrarily complex grammars. If you're willing to separate
namespaces for id attributes on A and B elements, this
might be possible using key/keyref (see 3.11.2 in XML
Schema Structures and/or 5.2 in XML Schema Primer).
 
J

Joseph Kesselman

IDs/IDREFs are pretty simpleminded. Since you're working in schema, you
may want to look at keys and keyrefs; I think it may be possible to
persuade them to do what you want.
 

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
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top