xsl-list
[Top] [All Lists]

RE: xsl needed: sibilings with different parents

2004-09-07 14:53:50
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(_at_)mhk(_dot_)me(_dot_)uk> 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(_at_)yahoo(_dot_)com] 
Sent: 07 September 2004 18:47
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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(_at_)yahoo(_dot_)com
http://www.apwebdesign.com

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam
protection around 
http://mail.yahoo.com 



--+------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--





--+------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--




=====
Anthony Ettinger
Phone: (408) 656-2473
apwebdesign(_at_)yahoo(_dot_)com
http://www.apwebdesign.com

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com