Re: [xsl] parameters in XSLT 2.0

Subject: Re: [xsl] parameters in XSLT 2.0
From: Bruce D'Arcus <bdarcus@xxxxxxxxx>
Date: Wed, 8 Jun 2005 08:17:52 -0400
On Jun 8, 2005, at 5:37 AM, Michael Kay wrote:

The only case where creating a temporary tree might be more efficient is if
it's optimized for subsequent processing, e.g. if it contains derived data,
sorted values, type annotations etc, that make subsequent computation
easier.

Right, which is the case in my stylesheets. Still, I get the feeling I may rely too much on temporary trees in my current code.


For example, first I have this variable to suck in outside data:

  <xsl:variable name="raw-biblist">
    <modsCollection xmlns="http://www.loc.gov/mods/v3";
      xmlns:bib="http://purl.org/NET/xbiblio/citeproc";>
      <xsl:copy-of select="$bibrecord/*/mods:mods"/>
    </modsCollection>
  </xsl:variable>

Then I have this variable, which creates the enhanced data you mention above:

<xsl:variable name="enhanced-biblist">
<mods:modsCollection xmlns:bib="http://purl.org/NET/xbiblio/citeproc";>
<xsl:choose>
<xsl:when test="$sort_order-bib='citekey'">
<xsl:apply-templates select="$raw-biblist/mods:modsCollection" mode="sort_citekey"/>
</xsl:when>
<xsl:when test="$sort_order-bib='cited'">
<xsl:apply-templates select="$raw-biblist/mods:modsCollection" mode="sort_cited"/>
</xsl:when>
<xsl:when test="$sort_order-bib='author-year'">
<xsl:apply-templates select="$raw-biblist/mods:modsCollection" mode="sort_author-year"/>
</xsl:when>
</xsl:choose>
</mods:modsCollection>
</xsl:variable>


... and then I do:

<xsl:variable name="bib:formatted-biblist">
<xsl:apply-templates select="$enhanced-biblist/mods:modsCollection/mods:mods"
mode="temp-placeholder"/>
</xsl:variable>


The thinking that prompted my question is that maybe the enhanced data gathered in the sort* modes in the second variable could be condensed down to a few (tunnel) parameters, rather than the 8 or so nodes I create in the temporary tree. If I understand right, that variable could also use an "as" attribute of element()*, because in that case I'd just be grouping and sorting, and applying templates with those parameters.

Is it worth asking these sorts of questions, then, at least as I look to optimize (e.g. after I get one or two more things working!)?

Bruce

Current Thread