I have a parent variable and two child variables for accumulate
I would like to use those two child variables to select two different values
I can only hardcode it to make it works like all other tutorial for example: $parent[1]/Price and $parent[1]/Quantity
but insteads I want the following:
$parent[1]/$child1 where $parent[1] = orders[1]/order and $child1 = price
$parent[1]/$child2 where $parent[1] = orders[1]/order and $child2 = quantity
<xsl:call-template name="total">
<xsl:with-param name="pList" select="$parent"/>
<xsl:with-param name="price" select="Price"/>
<xsl:with-param name="quantity" select="Quantity"/>
</xsl:call-template>
<xsl:template name="total">
<xsl:param name="pListItem"/>
<xsl:param name="pAccum" select="0"/>
<xsl:param name="price"/>
<xsl:param name="quantity"/>
<xsl:choose>
<xsl:when test="$pListItem">
<xsl:call-template name="total">
<xsl:with-param name="pListItem" select="$pListItem[position() > 1]"/>
<xsl:with-param name="pAccum"
select="$pAccum + $vHead/$price * $vHead/$quantity"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$pAccum"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Thanks a lot.
All I need is the '
Price
' and$vthisSale/*[name()=$pPriceName]
It really help!! I have been stuck for ages because of the magic ' '
It is not exactly clear what the question is, but my guess is this.
This transformation:
when applied on the following XML document (you could at least provide this!):
produces the wanted, correct result:
Do note: The values of the names of the child elements to serve as price and quantity are provided as external parameters to the transformation and can be known only at run-time.