xsl-list
[Top] [All Lists]

Re: [xsl] Efficiency problems while maintaining state

2007-05-23 15:20:23


Not sure that it helps but I'd probably approach your problem as below
(written as xslt2 but a similar version using xslt1 and node-set would
work)

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

  <xsl:strip-space elements="*"/>
  <xsl:output indent="yes"/>

  <xsl:template match="/">
    <xsl:variable name="p1">
      <xsl:apply-templates/>
    </xsl:variable>
    <xsl:apply-templates select="$p1" mode="p2"/>
  </xsl:template>
  
  <xsl:template match="*">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="dup">
    <xsl:variable name="x" as="node()*">
      <xsl:apply-templates/>
    </xsl:variable>
    <xsl:for-each select="1 to @times">
      <xsl:copy-of select="$x"/>
    </xsl:for-each>
  </xsl:template>
  
  <xsl:template match="*" mode="p2">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:attribute name="n"><xsl:number level="any"/></xsl:attribute>
      <xsl:apply-templates mode="p2"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

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