RE: [xsl] XSL:Copy w/ Processing Optimization Suggestions

Subject: RE: [xsl] XSL:Copy w/ Processing Optimization Suggestions
From: "Conal Tuohy" <conalt@xxxxxxxxxxxxxxx>
Date: Thu, 13 Mar 2003 15:20:23 +1300
I think the logic of your xsl:if is strange. Your template matches a lot of
things, and then sorts and copies them unless they are <part> elements with
a @DisplayValue='BM5125'? It looks to me as if your code would sort the
Body, Global, and Nav elements as well. Perhaps I'm seeing things :-)

>From your desired output it seems you are only interested in changing the
contents of the Results element. If so, you should define a template to
handle just this, and use an identity transform to handle the rest.

<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="Results">
  <xsl:copy>
    <xsl:apply-templates
select="Part[not(starts-with(@DisplayValue,'BM5125'))]">
      <xsl:sort order="ascending" select="@DisplayValue"/>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

Also NB I used the starts-with() function instead of contains(), since this
is bound to be slightly faster. :-)

Cheers!

Con


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


Current Thread