Re: [xsl] grouping + global variable (?) (was re: regexs,

Subject: Re: [xsl] grouping + global variable (?) (was re: regexs,
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Thu, 12 Aug 2004 18:07:56 -0400
Thanks Wendell,

On Aug 12, 2004, at 5:29 PM, Wendell Piez wrote:

2. Extended XSLT 1.0: create your first result by applying templates to your source and binding the results to a variable, which you then use a processor extension to turn into a node set for further processing. You'll probably need modes (if only to keep yourself sane), so:

<xsl:variable name="intermediate-result">
  <xsl:apply-templates select="/" mode="pass1"/>

<xsl:template match="/">
<xsl:apply-templates select="exslt:node-set($intermediate-result)" mode="pass2"/>

<xsl:template match="/" mode="pass1">
  <xsl:apply-templates select="pass1"/>

where exslt:node-set is an extension function that creates a node-set from a result-tree-fragment (see or consult your processor's documentation).

3. XSLT 2.0 -- same as 2, except no extension function is needed: it'll happen transparently.

I'm using XSLT 2.0; therefore, let me see if the light is dawning:

My pass1 mode is going to create an exact copy of the source bibliographic collection, with the only difference being that the year strings get the proper suffix appended.

Then when I run the second pass through my template that says has <xsl:value-of select="$year"/> I end up with the original year plus the suffix.

Is that the idea?

I had gotten confused because I was thinking that somehow I'd be creating an element or attribute with, say, the generated suffix, and accessing those with some sort of xpath expression; e.g. <xsl:value-of select="$biblist//mods[@id=$thisid]/suffix"/>.

That's the wrong way to think about it; correct?


Current Thread