Re: [xsl] number collapsing

Subject: Re: [xsl] number collapsing
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Tue, 14 Dec 2004 09:12:20 -0500
On Dec 14, 2004, at 8:59 AM, Michael Kay wrote:

One observation:

       <xsl:when test="$begin castable as xs:integer">
         <xsl:variable name="begin2" select="$begin" as="xs:integer"/>

This may fail if $begin is a string. The string "123" is castable to xs:integer, but not assignable to xs:integer.

I'm not following here. Aren't I saying in the function "if $begin is an integer, then apply this logic to determine how to shorten $end; if not, then just print $end as is"?


Better to write the second
line as

<xsl:variable name="begin" select="xs:integer($begin)" as="xs:integer"/>

to force the cast.

The problem is that I don't know if the page numbers will be integers (consider "iii").


I think your new problem can be tackled using a "group-starting-with". The
only problem is that this requires nodes rather than atomic values. So we'll
start by putting the numbers into a temporary tree:


<xsl:function name="f:ranges" as="xs:string">
  <xsl:param name="pagelist" as="xs:integer*"/>

Note that my issue here was actually applying not to page numbers, but to the in-text citation markers. However, now that I think about it more, the same issue could apply to page number. Does this suggest that I ought to have a single generic number collapsing function that could be used for both citation markers and for page numbers?


Bruce

Current Thread