W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2006

Re: Predicates in xpath expressions in <xs:selector>

From: George Cristian Bina <george@oxygenxml.com>
Date: Sat, 07 Oct 2006 19:12:57 +0200
Message-ID: <4527E019.2050808@oxygenxml.com>
To: Fermín Galán Márquez <fermin.galan@cttc.es>
CC: xmlschema-dev@w3.org

Hi,

The expressions used to specify the schema selector and field belong to 
a subset of XPath expressions and that does not include predicates, so 
it is a limitation of the schema and not a Xerces problem.

What you can do however is to specify both fields in a single 
constraint, like below for instance:

<xs:unique name="uniquiness">
    <xs:selector xpath="item" />
    <xs:field xpath="@name"/>
    <xs:field xpath="@type"/>
</xs:unique>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Fermín Galán Márquez wrote:
> Hi,
> 
> I'm experiencing problems using predicates in xpath attribute in
> <xs:selector> XMLSchema elements and I wonder if this is a problem of the my
> validator (xerces) or a limitation in the XMLSchema specification itself.
> 
> To detail the problem, let's consider a element (<item>) with a type
> attribute. The type attribute has two allowable values: "type1" and "type2".
> Element <item> has an additional name attribute, that must be unique in each
> "type-partition". I mean, the following is allowed:
> 
> <item type="type1" name="n1" />
> <item type="type1" name="n2" />
> <item type="type2" name="n1" />
> <item type="type2" name="n2" />
> 
> but this is forbidden:
> 
> <item type="type1" name="n1" />
> <item type="type1" name="n1" />
> 
> I'm trying to define the uniqueness with (in the parent <xs:element> of
> item):
> 
> <xs:unique name="uniquiness1">
>    <xs:selector xpath="item[@type='type1']" />
>    <xs:field xpath="@name"/>
> </xs:unique>
> <xs:unique name="uniquiness2">
>    <xs:selector xpath="item[@type='type2']" />
>    <xs:field xpath="@name"/>
> </xs:unique>
> 
> But, when trying to use this XMLSchema for validation, the validator tells:
> 'Xpath token not supported'
> 
> Is a problem of the validator or I'm trying to do something imposible with
> XMLSchema? Any clarification is welcome...
> 
> Thanks in advace!
> 
> Best regards,
> 
> --------------------
> Fermín Galán Márquez
> CTTC - Centre Tecnològic de Telecomunicacions de Catalunya
> Parc Mediterrani de la Tecnologia, Av. del Canal Olímpic s/n, 08860
> Castelldefels, Spain
> Room 1.02
> Tel : +34 93 645 29 12 
> Fax : +34 93 645 29 01
> Email address: fermin.galan@cttc.es 
> 
> PD. I've detected the problem in <xs:unique> but I suppose that the same
> applies to <xs:key>
> 
> 
Received on Saturday, 7 October 2006 17:08:45 GMT

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