473,224 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

trying to use xsl:choose to test for last page

I want to test to see if I am on the last page of a document. In this
example it is an invoice. I want to print a different table in REGION
AFTER when I am on the last page. I have tried many variations, no luck
yet. It seems like it should be an easy thing to do with xsl:choose.

Any ideas? Here is one of my attempts.
More detail of what the xml, xsl and pdf look like are here:
http://www.bangboompow.com/xml/invoice/
I am trying to test the field value in the footer area like this:

<xsl:choose>
<xsl:when test="document_end = 'TRUE'">
<fo:block font-size="10pt" font-weight="bold">
LAST PAGE
</fo:block>
</xsl:when>
<xsl:otherwise>
<fo:block font-size="10pt" font-weight="bold">
not the last page
</fo:block>
</xsl:otherwise>
</xsl:choose>

I am trying to set the value of the field in the detail line loop like
this:

<xsl:if test="position() = last()">
<xsl:variable name="document_end" select="'TRUE'" />
</xsl:if>

May 15 '06 #1
4 7731
> <xsl:if test="position() = last()">
<xsl:variable name="document_end" select="'TRUE'" />
</xsl:if>


Position doesn't refer to page number, but to position in a set of nodes
returned by an XPath expression.

Nothing in XSLT knows about the concept of "pages" per se.

If the XML language you're working in has a <page> element or something
equivalent to it, you could test for whether you are within the last
such element.

But I presume you're looking for something that will dynamically lay out
the document with an awareness of pagination. That isn't XSLT's job;
that's the sort of thing which the next stage of processing (XSL-FO, for
example) would handle.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
May 15 '06 #2

freefly_xml wrote:
I want to test to see if I am on the last page of a document.


This is really hard to do in any language remotely like XSLT. The
problem is that XSLT is largely data-centric, not layout-centric. You
need to think of a way of recognising "on the last page" for your
document that can be evaluated simply by looking at the data elements
in the source XML. In many cases this simply isn't possible. Actually
coding the thing as an XPath expression might be the easy bit.

Sometimes, in pathological cases, you have to perform the XML => XSL:FO
transformation (probably by XSLT) first. Once you're into XSL:FO then
you've fixed the layout, implied the page layout and you can start
looking at concepts like page number. Only then can you start
identifying "last page" -- probably by another XSLT identity transform
turning XSL:FO into XSL:FO, but with a minor template rule in there
identifying some condition and making a minor change.

May 16 '06 #3
freefly_xml wrote:
I want to test to see if I am on the last page of a document.


As Joe and Andy have explained, you can't easily do this unless
you are programming within a page-aware formatter. Normally this
kind of thing is handled by the print-formatter stylesheet.

Maybe within your template for Detail_Line you could add at
the end something like

<xsl:if test="not(following-sibling::Detail_line)">
stuff to do on last page
</xsl:if>

on the principle that if you're processing the last
Detail_Line, you're probably on the last page...

///Peter
--
XML FAQ: http://xml.silmaril.ie/
May 16 '06 #4
A working way to create a different footer for the last page of a
document with xslt.

In the looping of the detail lines test for the last line and set a
marker:

<xsl:choose>
<xsl:when test="position() = last()">
<fo:marker marker-class-name="footer-marker">
<fo:block>LAST PAGE</fo:block>
</fo:marker>
</xsl:when>
<xsl:otherwise>
<fo:marker marker-class-name="footer-marker">
<fo:block>Continued...</fo:block>
</fo:marker>
</xsl:otherwise>
</xsl:choose>

then retrieve the marker in the region-after with this:

<fo:retrieve-marker retrieve-position="last-ending-within-page"
retrieve-class-name="footer-marker" />

May 16 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ruthless | last post by:
Hello. I've got a question about xsl:choose I've got an element <person> with the sequence of <first_name><last_name><date_bith> and <info> and the info is not obligatory(minOccurs="0") ...
0
by: Chris Huebsch | last post by:
Hello, I have a Real-World-XSLT-Problem.(tm) That is: A XML-Document of about 75.000 elements contains <person>-elements at various depths of the tree. Each person consists of a <name>,...
0
by: thomas | last post by:
I was wandering if theres a way to make a .xsl page output 20 results per page. My page transforms an .xml file but as its a large file, it outputs hundreds of results on the same page. heres my...
4
by: Christofer Dutz | last post by:
Hi, I am having a small problem, that is driving me nuts. My application reads some Xml and runs 2 Xsl Transformations to generate HTML. As soon as my second XSL introduces some <br/tags, the...
4
by: RigasMinho | last post by:
Hello, I have an issue where i have a link in a web page using XSL - for example says its <a href="http://www.test.com/&testme=03/27/2007" target="_blank">Test</ a> notice the date is...
2
by: McGowan | last post by:
Hi, Trying to display only a certain type of data depending on a variable passed through a url. For example if I had a list of CDs and I wanted to display only the ones by greenday I would pass...
0
by: sandydon | last post by:
when am trying this in xsl page <xsl:variable name="myArray"><item>item1</item><item>item2</item></xsl:variable> <xsl:value-of select="$myArray/item"/> i got the following error HTTP...
1
by: shalini jain | last post by:
Hi, I want to know how can we do pagination using XSL. There are number of tutorials available on pagination using PHP but nothing with XSL. i am really stuck with my code. Below is the code that...
1
by: mrbadboy | last post by:
Hi, I need to display image in xsl page from XML node. Is it possible to display it without using any <img> tag in xsl page ? Thanks
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.