[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Fwd: fail to alter rendering effects with different pages by appling position() mod 2 = 1


Subject: Re: [xsl] Fwd: fail to alter rendering effects with different pages by appling position() mod 2 = 1
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sun, 11 Sep 2011 12:26:58 -0400

Before your questions can be answered, there are some clarifications needed.

At 2011-09-12 00:22 +0800, team wise wrote:
My problem being,  the XSL FO cannot be applied differently to
different pages, for example, on the last page,  the
axf:background-color attribute and its value should have been applied
in the resulting PDF.

Of course XSL-FO can be set up such that different properties are applied to different pages in a page sequence, including the last page.


Previoulsy, the following line of code works just fine:

This code that you quote is doing the test in the XSLT, it is not setting up the last-page contingencies in the XSL-FO:


///////////////////
  <xsl:if test="$outputformat = 'UG_Booklet_Print'">
        <xsl:choose>
          <xsl:when test="position() = last()">
            <xsl:attribute name="axf:background-color"><xsl:value-of
select="$background_colour"/></xsl:attribute>
            <xsl:attribute
name="color">rgb-icc(#CMYK,0%,0%,0%,0%)</xsl:attribute>
          </xsl:when>
          <xsl:when test="position() mod 2 = 1">
            <xsl:attribute
name="axf:background-color">rgb-icc(#CMYK,0%,0%,0%,10%)</xsl:attribute>
            <xsl:attribute
name="color">rgb-icc(#CMYK,0%,0%,0%,80%)</xsl:attribute>
          </xsl:when>
          <xsl:otherwise>
            <xsl:attribute
name="color">rgb-icc(#CMYK,0%,0%,0%,80%)</xsl:attribute>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:if>
//////////////////////////////

So, you are mixing questions of XSLT and questions of XSL-FO. The above code implies that you are forcing (or assuming) one page per page sequence, such that you can control the properties of the page sequence at the time you create the page sequence.


Typically in XSL-FO one sets up a page-sequence-master with different simple-page-master declarations of the use of background colours for the regions. The odd/even is tested using conditional page master alternatives.

You have nothing of that in this post, so I can only assume that you have chosen to do such testing in your XSLT and force one page per page sequence. You are doing a lot of work that the formatter can do for you.

And for readers of the archive, they may be misled that such problems might be solved in XSLT when, in fact, they are better solved by letting the formatter deal with them.

 after the modifications I made to XSLs today, the resulting PDF
indicates that either position() = last()" or position() mod 2 = 1 can
work as expected, but not all work simultaneously, subject to proper
conditions. Specifically,

Specifically, what? You don't indicate what your modifications are.


My question , how can I make XSL FO treat different pages differently
as it used to be?

How can anyone answer your question if you don't indicate what the new code is in order to compare it to the old code?


I greatly appreciate if there is any hint.

I suggest you clarify your question and you justify your use of XSLT for such tests rather than setting up the XSL-FO formatter to handle page parity (odd/even) and page position (first/last/rest).


I hope this helps.

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

--
Contact us for world-wide XML consulting and instructor-led training
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal


Current Thread
Keywords