RE: [xsl] Apply template?

Subject: RE: [xsl] Apply template?
From: cknell@xxxxxxxxxx
Date: Wed, 16 May 2007 11:24:47 -0400
No, Danny. Sorting is the main reason for <xsl:for-each>. 
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Danny Leblanc <leblancd@xxxxxxxxxxxxxxxxxxx>
Sent:     Wed, 16 May 2007 11:01:45 -0400
To:       <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject:  [xsl] Apply template?

Good day everyone,

  I have read in the past here that most people who are not "used" to XSLT tend to use for-each when an apply template would be the better route. I have received the following XSLT file.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  <xsl:template match="/">
    <A>
      <B>
         <xsl:for-each select="/A/B/C">
          <xsl:sort order = "ascending" data-type = "number" select = "D"/>
          <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
          </xsl:copy>
        </xsl:for-each>
      </B>
    </A>
  </xsl:template>
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

  In a case like this, would there be a better way to handle this using apply templates? Would there be a performance gain by using apply templates instead? I tried to put one together but to date have not had much success but just wanted to ensure that switching to apply templates would be the correct way to go.

  Thank you for all advice given.

Danny

Current Thread