[xsl] Using saxon:assign and testing content of variable

Subject: [xsl] Using saxon:assign and testing content of variable
From: Dan Vint <dvint@xxxxxxxxx>
Date: Tue, 20 Sep 2005 10:55:30 -0700
I'm still working on my Index. Now I'm trying to gather the index terms up and group them and then generate the page numbers.

I'm using Saxon 6.5 and the group and item extensions to make this process reasonable. I've got the headings seeming to work properly up to 3 levels with see and see also support. Now I'm trying to gather up the page numbers with their markup and output them as a single statement once all the page numbers are gathered.

The process I wrote myself into has me collecting the page numbers in a variable that I can assign to with another saxon function. This was the template I had written:

<xsl:template name="page-sequence">
     <xsl:param name="NumberPage" select="false()" />

<xsl:if test="$NumberPage">
<xsl:when test="$pageNumber=''">
<saxon:assign name="pageNumber">
<fo:leader leader-pattern="dots" leader-length="1in" />
<fo:basic-link internal-destination="{generate-id()}">
<fo:page-number-citation ref-id="{generate-id()}" />
<!-- similar stuff here for continuation -->

As you see I'm assigning the <fo> markup to the variable and in the otherwise, I was adding additional page numbers with a comma separator.

What I'm at a loss for is the proper test in the <choice> to see if there is content in $pageNumber.

First what is the proper way to reset the variable to be empty and hopefully no nodes in the node-set? Does a simple <saxon:assign name="pageNumber"/> do it?

What is the best test to detect content in $pageNumber? I tried count() but it always returns 1, and the test for the empty string is not working either.


Danny Vint

Specializing in Panoramic Images of California and the West

voice: 510-522-4703

Current Thread