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

Subject: RE: [xsl] xsl needed: sibilings with different parents
From: Anthony Ettinger <apwebdesign@xxxxxxxxx>
Date: Tue, 7 Sep 2004 14:53:50 -0700 (PDT)
Thanks Michael, However in my architecture we have not
yet introduced variables.

Do you think something like this would work instead,
without using variables?

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

I'm actually not using straigt xsl, I have xml which
is transformed into xsl, and in my context I have
something like this:

<Iteration>
<RepeatingUnit>BB/BB1</RepeatingUnit>
<RepeatingAction>
<Result>/root/AA/[position of BB1]</Result> <-- xpath
can go here
</RepeatingAction>
</Iteration>


--- Michael Kay <mhk@xxxxxxxxx> wrote:

> 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 
> 
> 


=====
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