Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Starting Initial Page Number on Page Three

From: "G. Ken Holman" <gkholman@-------------------->
To:
Date: 3/5/2009 1:52:00 AM
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent