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

Dear George,

Thank you! You solution works perfectly! :)

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  

-----Mensaje original-----
De: George Cristian Bina [mailto:george@oxygenxml.com] 
Enviado el: sábado, 07 de octubre de 2006 19:13
Para: Fermín Galán Márquez
CC: xmlschema-dev@w3.org
Asunto: Re: Predicates in xpath expressions in <xs:selector>

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:35:57 UTC