xsl-list
[Top] [All Lists]

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

2011-10-04 01:14:36
Hi Tony,

With your amended code, I have injected it to the existing XSL, which
fails to output desirable PDF once again when working through the
Input XML.

I think one vital thing I did not made it clear enough in the first
place here is :

Instead of  the input you depicted below,  the correct ' input' is in
fact something like this:

---------------------------------------
<Map>
 <topicref href="GUID-1234">                 <concept id="guid-5678"
outputclass="pagebreak">
  Phone basics                                 <title>Explore and get
suppport</title>
 </topicref>                                   <conbody/>
 <topicref href="GUID-5678">       ------->  <concept>
 Explore and get support
 </topicref>
</Map>
---------------------------------------

On the same note, I did notice , when Antenna House compiled FO to the
resulting PSMI , it complained about the missing Page Master name. I
overcome it by ' refacoring the relevant 'Master-Reference'.
In short, when i debugged the specific piece of code  by
<xsl:message/>, it appears that that specific line of code does not
function at all. That  is why I explicitly specify the ' input' above.

Please could you advise?

Thank you,
2011/10/3 Tony Graham <tgraham(_at_)mentea(_dot_)net>:
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(_at_)mentea(_dot_)net
Consultant                                 http://www.mentea.net
Mentea       13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
 --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
   XML, XSL FO and XSLT consulting, training and programming


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





-- 
Keep an Exacting Eye for Detail

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>