xsl-list
[Top] [All Lists]

Re: Traversing the tree

2005-09-08 15:54:51



  <xsl:variable name="reg">
    <xsl:for-each select="//reg">
      <xsl:copy-of select="."/>
    </xsl:for-each>
  </xsl:variable>

..
      <xsl:when test="$reg/

Note that's not legal in XSLT1 (as $reg is a result tree fragment) it's
legal but expensive in xslt2 (as you have to copy all the nodes)

better to do

  <xsl:variable name="reg" select="//reg"/>

An alternative strategy would be


<xsl:stylesheet version="1.0"
              xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:template match="top">
<xsl:for-each select="a/reg">
:<xsl:variable name="x" 
select="(.|preceding-sibling::reg)[(_at_)offset][last()]"/>
<xsl:value-of select="."/>:  <xsl:value-of select="sum($x/@offset) +
    count(preceding-sibling::reg) - count($x/preceding-sibling::reg)"/>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>


David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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