RE: [xsl] xsl needed: sibilings with different parents

Subject: RE: [xsl] xsl needed: sibilings with different parents
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Tue, 7 Sep 2004 19:52:33 +0100
Easy in XPath 2.0:

for $i in 1 to count(BB/BB1)
return (BB/BB1[$i], AA/AA1[$i])

Just slightly more verbose in XSLT 1.0:

<xsl:variable name="root" select="."/>
<xsl:for-each select="BB/BB1">
  <xsl:variable name="i" select="position()"/>
  <xsl:copy-of select="."/>
  <xsl:copy-of select="$root/AA/AA1[$i]"/>
</xsl:for-each>

Michael Kay

> -----Original Message-----
> From: Anthony Ettinger [mailto:apwebdesign@xxxxxxxxx] 
> Sent: 07 September 2004 18:47
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] xsl needed: sibilings with different parents
> 
> Hi,
>  
> I've the following document:
>  
> <root>
>   <AA>
>         <AA1/>
>         <AA1/>
>         <AA1/>
> ......
>   </AA>
>   <BB>
>         <BB1/>
>         <BB1/>
>         <BB1/>
> ......
>   </BB>
> </root>
>  
> I need to loop on BB/BB1 and within the loop, I need
> to use the index or position of BB/BB1 and access
> AA/AA1 to get the corresponding AA/AA1's value each
> time.
>  
> Any thoughts?
>  
> Thank you
> 
> =====
> Anthony Ettinger
> Phone: (408) 656-2473
> apwebdesign@xxxxxxxxx
> http://www.apwebdesign.com
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 

Current Thread