You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by Ol...@vodafone-us.com on 2002/07/29 22:09:20 UTC

complex XPath queries

Is it possible to express a "join" query  involving more than 2 sibbling
nodes ? I have not found anything similar in the XPath tutorials.

example:

<DOC>
     <A id="1"/>
     <B id="1"/>
     <C id="1"/>
</DOC>


I would like to express: //A/@id = //B/@id = //C/@id

Is something like: //A/@id = //B/@id and //A/@id = //C/@id works ?

Olivier


Re: complex XPath queries

Posted by "Robert S. Koberg" <ro...@koberg.com>.
Hi,

Olivier.Brand@vodafone-us.com wrote:
> Is it possible to express a "join" query  involving more than 2 sibbling
> nodes ? I have not found anything similar in the XPath tutorials.
> 
> example:
> 
> <DOC>
>      <A id="1"/>
>      <B id="1"/>
>      <C id="1"/>
> </DOC>
> 
> 
> I would like to express: //A/@id = //B/@id = //C/@id
> 
> Is something like: //A/@id = //B/@id and //A/@id = //C/@id works ?
>

How about using a key (defined at the top level):

<xsl:key
    name="the_key"
    match="A | B | C"
    use="@id"/>  <!-- perhaps match * -->


Then pass the id:

key('the_key', $id)

This will give you all the nodes matching the ID. Is this what you want?

best,
-Rob