[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Efficiency problems while maintaining state


Subject: Re: [xsl] Efficiency problems while maintaining state
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 23 May 2007 23:19:52 +0100

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. 
________________________________________________________________________


Current Thread