[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Suggestion: transparent id-ref traversal with XPath?


Subject: RE: [xsl] Suggestion: transparent id-ref traversal with XPath?
From: "Americo Albuquerque" <aalbuquerque@xxxxxxxxxxxxxxxx>
Date: Sun, 20 Jul 2003 11:54:12 +0100

Hi.

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Gunther Schadow
> Sent: Monday, May 19, 2003 10:06 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Suggestion: transparent id-ref traversal with XPath?
> 
> 
(...)
> Now this is easy to do with some ID/IDREF trick:
> 
> <order>
>    <billingAddress id="1">
>       ...
>    </billingAddress>
>    <shippingAddress ref="1"/>
> </order>
> 

You could use keys:
<xsl:key name="bill" match="billingAddress" use="@id"/>
<xsl:key name="ship" match="shippingAddress" use="@ref"/>

And use key('ship',@id) to get the shippingAddress from billingAdress or
key('bill',@ref) to get billingAdrress from shippingAdrress

The xpath will be *[@id=key('ship',@id)/@ref]/mapLocation  or
*[@id=key('ship',@id)/@ref]/mapLocation | key('ship',@id)/mapLocation

The same could be done in shippingAdress:
*[@ref=key('bill',@ref)/@id]/mapLocation  or
*[@ref=key('bill',@ref)/@id]/mapLocation | key('bill',@ref)/mapLocation

Hope this helps

  Americo Albuquerque




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords