W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2002

How to reference attributes from list items

From: Eric Jain <Eric.Jain@isb-sib.ch>
Date: Fri, 6 Sep 2002 11:57:44 +0200
Message-ID: <009d01c2558b$d8f97f40$2fd721c0@caliente>
To: "xmlschema-dev" <xmlschema-dev@w3.org>

Sorry, another unanswered and recycled question (from comp.text.xml):

Is it possible to create a schema that asserts that the first element
of a list refers to an attribute? Example:

<entry key="103">
    <list>
        <item>103</item>
        <item>101</item>
        <item>204</item>
    </list>
</entry>

As a first step, the key attribute can be defined to be a key, no
problem there:
 
<xsd:key name="entryKey">
    <xsd:selector xpath="entry"/>
    <xsd:field xpath="@key"/>
</xsd:key>

Now I can have *all* items refer to the key attribute of their entry
(or another one, depending on the scope):

<xsd:keyref name="key-ref" refer="entryKey">
    <xsd:selector xpath="entry/list/item"/>
    <xsd:field xpath="."/>
</xsd:keyref>

But now how do I limit this restriction to the first element of the
list? This doesn't work:
 
<xsd:keyref name="key-ref" refer="entryKey">
    <xsd:selector xpath="entry/list"/>
    <xsd:field xpath="item[1]"/>
</xsd:keyref>

Any ideas? Or is this in fact a limitation of W3C Schema? There is
some mention of 'XPath subset' in http://www.w3.org/TR/xmlschema-1/,
but I couldn't find any further details. Alternative strategies?


--
Eric Jain
Received on Friday, 6 September 2002 05:57:40 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:34 GMT