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

Re: [xsl] Conditionally have an even page declaration


Subject: Re: [xsl] Conditionally have an even page declaration
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 11 Jan 2012 15:48:28 -0500

At 2012-01-11 13:33 -0600, Colin DeClue wrote:
Is it possible to conditionally define an even page, based on
something in the xml?

Yes, but I think not with the approach you've taken. Though I am unsure based on the lack of detail in your question.


I'm trying to do something with <xsl:if>, but I
can't seem to get it to work, and I can't find good examples anywhere
of using it not in a for-each.

This is what I have:

        <xsl:if test="BolReport/ReportType = 'Term'">
          <fo:simple-page-master master-name="even"
            page-width="8.5in"   page-height="11in"
            margin-top="0.13in"  margin-bottom="0.25in"
            margin-left="0.175in" margin-right="0.25in"
background-image="url({BOLReport/TermPath})">
            <fo:region-body/>
          </fo:simple-page-master>
        </xsl:if>

The simple page master can be in your layout master set and never used, so it is safest to simply add it without putting it in the conditional.


And then in the xml:

<BOLReport>
  ...
  <ReportType>Term</ReportType>
  ...
</BOLReport>

Is that your document element or a piece of your document? I'll assume it is a piece of your document and I'm guessing you are creating a page sequence for each of the <BOLReport> elements:


   <xsl:for-each select="BOLReport">
     <fo:page-sequence master-reference="regular">
        <xsl:if test="ReportType='Term'">
          <!--override the regular master to force an even page-->
          <xsl:attribute name="master-reference">even</xsl:attribute>
          <xsl:attribute name="page-number">auto-even</xsl:attribute>
        </xsl:if>
        ...
     </fo:page-sequence>
   </xsl:for-each>

I hope this helps, though I'm unclear on precisely what you are asking for. Perhaps this will point you in the right direction.

. . . . . . . . . Ken

--
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/uoui9h
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
xml