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">

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"/>

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="."/>

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]"/>

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

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:58 UTC