Re: [xsl] union vs. "or" vs. contains?

Subject: Re: [xsl] union vs. "or" vs. contains?
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Tue, 19 Oct 2004 06:51:36 -0400
On Oct 19, 2004, at 4:54 AM, David Carlisle wrote:

To expand on what Mike said, All of the three look a little suspicious.
they are written using filter syntax, but the filter predicate doesn't
depend on the current node so really it's a global switch.

Since they are in match patterns where you are not allowed to have a top
level if test, this may be what you want, but...

Yes, it's a global switch. I've done it this way because I wanted to modularize the code as much as possible.


So, the citation style config files have an attribute on the root called "class" which is used both to drive the validation of the rest of the schema, and to structure the xsl code. Each class has quite different processing needs, and so I put that code not just in class-specific templates, but even in their own files/directories.

I guess you guys are telling me they way I've done this -- to condition the processing based on a variable -- may slow things down a bit? (It would indeed help if Saxon could do what Mike suggested w/respect to pre-evaluating.)

The variable itself, BTW, is defined like this:

<!-- read the external citation style file -->
<xsl:param name="citation-style" required="yes" as="xs:string" />

<xsl:variable name="styles" as="document-node()"
  select="doc(concat('../../styles/',$citation-style, '.csl'))" />

<!-- set the citation class parameter (e.g. author-year) as specified in the style file -->
<xsl:param name="citation-class" select="$styles/cs:citationstyle/@class"/>


So, I guess the alternative is something like the following on every main template?

<xsl:template match="[doc(concat('../../styles/',$citation-style, '.csl')/cs:citationstyle/@class='citekey')]">

Bruce

Current Thread