|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: accessing previously created element
At 01:07 PM 5/1/2002, you wrote:
unfortunately when transforming the i'th 'a' element to a 'b' (assume i > 1) I also need to access the (i-1)'th 'b' element; that is, the values used to create a 'b' element are dependent upon the current 'a' element being transformed and the preceding 'b' element. Is this possible? in a single pass? Not making any claims about efficiency, it looks like you'll need to use recursion and hope that your XSLT engine creates each previous node only once and stores it somewhere internally. <xsl:template name="b-from-a">
<xsl:param name="local-a" />
<xsl:choose>
<xsl:when test="not($local-a)">
<!-- Shouldn't be reached unless your initial call is bogus. -->
</xsl:when>
<xsl:when test="$local-a/preceding-sibling::a[1]">
<xsl:variable name="prev-b">
<xsl:call-template name="b-from-a">
<xsl:with-param select="$local-a/preceding-sibling::a[1]" />
</xsl:call-template>
</xsl:variable>
<!--
Use $local-a and $prev-b to construct "b"
-->
<xsl:value-of select="..." />
</xsl:when>
<xsl:otherwise>
<!--
First occurrence (i == 1)
Construct it however you normally do it.
-->
<xsl:value-of select="..." />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








