xsl-list
[Top] [All Lists]

Re: [xsl] For each with parallel nodelist

2006-08-31 11:07:08

<xsl:for-each
select="/CommandList/CheckRouting/RouterList/Router[Complete='true']/GroupLi
st/Group/OutwardList/Outward" >
<xsl:variable name="root"
select="/CommandList/CheckRouting/RouterList/Router[Complete='true']/GroupLi
st/Group/ReturnList/Return" />


the variable here does not depend on the current node set up by the
for-each so $root will have the same value on every iteration. If you
are lucky your processor's optimiser willl re-write teh expression to
take the constant subterm out of the loop and write it as

<xsl:variable name="root"
select="/CommandList/CheckRouting/RouterList/Router[Complete='true']/
GroupList/Group/ReturnList/Return" />

<xsl:for-each
select="/CommandList/CheckRouting/RouterList/Router[Complete='true']/
GroupList/Group/OutwardList/Outward" > 

again this clause will have the same value at each iteration.
<xsl:otherwise>
<xsl:value-of select="//Group/Price/Amount/text()"/>


The problem is <xsl:value-of select="number($root/Price/Amount)"/>
Return the same results...

It's cleay why $root has teh same value at each iteration, but as you
haven't shown your input form or what you intend to calculate it's a bit
hard to suggest what changes to make.

Perhaps you want
<xsl:for-each
select="/CommandList/CheckRouting/RouterList/Router[Complete='true']/
GroupList/Group/OutwardList/Outward" > 
<xsl:variable name="root" select="../../ReturnList/Return" />

and I suspect that you want that otherwise clause to also depend on the
current node, something like
<xsl:otherwise>
<xsl:value-of select="../../Price/Amount"/>

It may be simpler to for-each over just Groups

<xsl:for-each
select="/CommandList/CheckRouting/RouterList/Router[Complete='true']/
GroupList/Group">
<xsl:variable name="root" select="ReturnList/Return" />

etc but without knowing what transformation you intend it's hard to say.

David


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

<Prev in Thread] Current Thread [Next in Thread>