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

Re: [xsl] how to trigger a new page sequence, depending on specific input conditions


Subject: Re: [xsl] how to trigger a new page sequence, depending on specific input conditions
From: "Tony Graham" <tgraham@xxxxxxxxxx>
Date: Mon, 3 Oct 2011 12:11:23 +0100 (IST)

On Mon, October 3, 2011 10:59 am, team wise wrote:
> I was grateful to your patience in guiding me through the problem
> solving scenario.

There's any number of people on this list who would have been able to
help, and often do.  It just happened that I replied first.

> When I applied the original line of code you indicated below,
> <xsl:apply-templates  select=".
> |preceding-sibling::*[count(preceding-sibling::concept[title/@outputclass='pagebreak']
> = $position - 1" />
> the command line threw errors when running against Saxon 6.5.5 as XSLT
> processor. Obviously, it missed a pair of both square bracket and
> bracket.  I have just made amendments to it and the resulting code is

It was untested, sorry about that.

It seems that your correction closed the count() in the wrong place.

For this input:

---------------------------------------
<UG_Booklet_Print>
<concept>
 <title xtrf="GUID-1234">
  Explore and get support
 </title>
 <conbody/>
</concept>
<concept  outputclass="pagebreak">
 <title xtrf="GUID-1234">
  Explore and get support
 </title>
 <conbody/>
</concept>
<concept>
 <title xtrf="GUID-1234">
  Explore and get support
 </title>
 <conbody/>
</concept>
</UG_Booklet_Print>
---------------------------------------

this stylesheet:
---------------------------------------
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
    version="1.0">

<xsl:param name="outputformat" select="'UG_Booklet_Print'" />
<xsl:param name="background_colour" select="'dodgerblue'" />

<xsl:template match="UG_Booklet_Print">
  <xsl:if test="$outputformat = 'UG_Booklet_Print'">
    <xsl:for-each select="*[contains(@outputclass, 'pagebreak')]">
      <xsl:variable name="position" select="position()" />
      <fo:page-sequence initial-page-number="auto" format="1">
	<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:otherwise>
            <xsl:attribute
		name="color">rgb-icc(#CMYK,0%,0%,0%,80%)</xsl:attribute>
          </xsl:otherwise>
        </xsl:choose>
	<xsl:apply-templates
	    select=". |
		    preceding-sibling::*[count(preceding-sibling::*[contains(@outputclass,
				     'pagebreak')]) = $position - 1]" />
      </fo:page-sequence>
    </xsl:for-each>
    <xsl:if
	test="*[contains(@outputclass, 'pagebreak')][last()]/following-sibling::*">
      <fo:page-sequence initial-page-number="auto" format="1">
	<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:otherwise>
            <xsl:attribute
		name="color">rgb-icc(#CMYK,0%,0%,0%,80%)</xsl:attribute>
          </xsl:otherwise>
        </xsl:choose>
	<xsl:apply-templates
	    select="*[contains(@outputclass,
'pagebreak')][last()]/following-sibling::*" />
      </fo:page-sequence>
    </xsl:if>
  </xsl:if>
</xsl:template>

</xsl:stylesheet>
---------------------------------------

gives this output with xsltproc:

---------------------------------------
<fo:page-sequence xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
initial-page-number="auto" format="1" axf:background-color="dodgerblue"
color="rgb-icc(#CMYK,0%,0%,0%,0%)">

  Explore and get support




  Explore and get support


</fo:page-sequence><fo:page-sequence
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
initial-page-number="auto" format="1" axf:background-color="dodgerblue"
color="rgb-icc(#CMYK,0%,0%,0%,0%)">

  Explore and get support


</fo:page-sequence>
---------------------------------------

Regards,


Tony Graham                                   tgraham@xxxxxxxxxx
Consultant                                 http://www.mentea.net
Mentea       13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
 --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
    XML, XSL FO and XSLT consulting, training and programming


Current Thread
Keywords