Re: [xsl] Condition problem

Subject: Re: [xsl] Condition problem
From: "C. M. Sperberg-McQueen" <cmsmcq@xxxxxxxxxxxxxxxxx>
Date: Wed, 4 Nov 2009 11:08:40 -0700
On 4 Nov 2009, at 03:29 , Michael Kay wrote:
... First some comments:

<xsl:when test="matches(.,'-') or matches(.,'-')">

Why repeat the condition?

Actually, the two literals being tests are different characters (here, and elsewhere in the code where there appear at first glance to be duplicate tests): hyphen and en-dash.

It looks to me as if in cutting down the problem you omitted
some crucial control structures; I guess your full code contains
one or more for-each constructs to iterate.

Without the code in front of us it's hard to be sure, but from
the sample output you give, my guess is that when generating
the refid attribute your full code first looks for ranges
and supplies the items in the range, and then handles all of
the cr children that are not either the start or the end of
a range.  And (again, judging from your sample input and
output), you want the items mentioned in the refid attribute
to be listed in the order in which they appear (explicitly or
implicitly) in the cr elements in the document.

My first advice would be: replace the contents of

  <xsl:attribute name="refid">
   ...
  </xsl:attribute>

with a call to apply-templates, using a new mode:

<xsl:attribute name="refid">
<xsl:apply-templates mode="supply-refid-target-values" select="cr"/>
</xsl:attribute>


Then write three templates to handle the three kinds of cr
elements you have:

  (1) a cr element followed by a hyphen or an en-dash; it
      begins a range, so find the end of the range and emit
      the appropriate bibNN tokens, separated by blanks
  (2) a cr element preceded by a hyphen or an en-dash;
      it ends a range, so it has been handled by the
      first template, and should do nothing
  (3) any other cr element (followed by comma or nothing);
      it isn't a range, so just emit its bibNN token and
      a trailing blank

I hope this helps.

Michael Sperberg-McQueen


-- **************************************************************** * C. M. Sperberg-McQueen, Black Mesa Technologies LLC * http://www.blackmesatech.com * http://cmsmcq.com/mib * http://balisage.net ****************************************************************

Current Thread