How to reference attributes from list items

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 UTC