Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] accessing previously created element

From: Greg Faron <gfaron@------------------>
To:
Date: 5/1/2002 11:48:00 AM
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>


Greg Faron
Integre Technical Publishing Co.





XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent