[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Starting Initial Page Number on Page Three

Subject: Re: Starting Initial Page Number on Page Three
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 04 Mar 2009 20:48:27 -0500
Re:  Starting Initial Page Number on Page Three
At 2009-03-04 17:27 -0800, Horace Burke wrote:
Yes, I tried my modified template. It didn't change anything. The page number still starts at three "3" -- I am sure I am doing something wrong.

I have a guess ... but you don't show us your input data.


The template is applied by default rules.

Okay, so with the built-in template rules, that is in effect doing the following:


   <xsl:template match="some-element">
     <xsl:apply-templates/>
   </xsl:template>

So that means if you have the data:

   <some-element>
      <lang>
        ....stuff....
      </lang>
      <lang>
        ....stuff....
      </lang>
      <lang>
        ....stuff....
      </lang>
   </some-element>

And your template reads as follows:

 <xsl:template match="lang">
        <fo:page-sequence master-reference="Insrt-body-page">

<xsl:if test="position() = 1">
<xsl:attribute name="initial-page-number">1</xsl:attribute>
</xsl:if>

... then <lang> is *not* the first child node of <some-element> and you won't get your attribute. It is the first element node. The first child node is the text node with the indentation of the <lang> element's start tag. The position() would be returning "2" in the illustration above, which is why you aren't getting initial-page-number="1".


Do you only have element children below <some-element>? If so, you could avoid the built-in template rules and do the following:

   <xsl:template match="some-element">
     <xsl:apply-templates select="*"/>
   </xsl:template>

... which will only push the element children to your stylesheet.

Or if you only have <lang> children you could do:

   <xsl:template match="some-element">
     <xsl:apply-templates select="lang"/>
   </xsl:template>

Then if the first <lang> is the first element child of <some-element> then the position() function would return "1" and you would get your initial-page-number="1".

I hope I've guessed right and this helps. It is a common issue when dealing with the built-in template rules and indented data.

. . . . . . . . . . . . Ken

--
XQuery/XSLT training in Prague, CZ 2009-03 http://www.xmlprague.cz
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.