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

Subject: Re: [xsl] Using saxon:assign and testing content of variable
From: Dan Vint <dvint@xxxxxxxxx>
Date: Tue, 20 Sep 2005 15:50:44 -0700
What you see is the first level of content that only gets added to the variable when a page number should be generated. In that choice you see one use I need to tell if I have been through this loop once already or not as the <otherwise> adds additional page numbers and a comma. So I'm trying to test the content of the variable to see if something has been assigned already.

I thought that a count($pageNumber) would have returned 3 for the 3 nodes I added to the variable, instead I get a consistent 1.

..dan

At 02:43 PM 9/20/2005, David Carlisle wrote:

> 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?

ther's no "proper" way to reset a variable in a functional
language saxon:assign really cuts across the whole declarative language
paradigm and really once you use something like that you aren't really
using XSLT at all.

However I don't understand your comment

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

You don't need to test this you know exactly the content of the variable
                               <fo:leader leader-pattern="dots"
leader-length="1in" />
                               <fo:basic-link
internal-destination="{generate-id()}">
                                     <fo:page-number-citation
ref-id="{generate-id()}" />
                                </fo:basic-link>

so it is a result tree fragment corresponding to those elements.

I can't really tell from the small fragment that you posted but I
suspect that you are trying to get XSLT to process page numbers and
other values calculated by an FO engine. That never works,the XSLT
process does not know _anything_ about XSLFO and XSLFO does not know
_anything_ about XSLT. As far as the xslt is concerned there is nothing
special about  <fo:page-number-citation>  it could just as well be
<jhgifgi> it's just an element node in a result tree. XSLT has to
construct the entire FO document to be processed and teh XSLT
transformation finishes before the FO engine starts.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--------------------------------------------------------------------------- Danny Vint

Specializing in Panoramic Images of California and the West
http://www.dvint.com

voice: 510-522-4703

Current Thread