xsl-list
[Top] [All Lists]

generate-id and page-number-citation

2003-04-08 01:41:12
I have enclosed  a snippet of the source code. This should make
clear  the extent of my problem.
I have made comments in capitals throughout the source code. The
problem is a combination of 'generate-id' and
'page-number-citation'. Maybe there's a lot easier way to do
this, but I'm stuck.

<?xml version="1.0"
encoding="ISO-8859-1"?>
<!--==============================================================
============
 !      Author: KathrinC

!=================================================================
========-->
<xsl:stylesheet version="1.0" 
    xmlns:xsl=      "http://www.w3.org/1999/XSL/Transform";
    xmlns:lxslt=    "http://xml.apache.org/xslt"; 
    xmlns:fo=       "http://www.w3.org/1999/XSL/Format";

 
<!--==============================================================
========
   !  Global Variables
  
!=================================================================
====-->
  <xsl:variable name="toc.two"       select="'a'"/>
  <xsl:variable name="toc.three"     select="'b'"/>
    
<!-- FLOW     -->
       <fo:flow flow-name="xsl-region-body">
              <xsl:call-template name="Coverpage"/>

<!-- START OF  FOR-EACH BLOCK WHERE I WOULD ACTUALLY LIKE TO
GENERATE MORE THAN ONE ID  -->
<!-- HOW CAN I DO THIS ??? -->
<!--                           THERE CAN BE SEVERAL
'First_Collection's   -->                          
              <xsl:for-each select="First_Collection">
                
                  <fo:block break-before="page">
                     <xsl:call-template name="GenerateID"/>
                  </fo:block>
<!--                           FOR EACH 'First_Collection's
'BLOCK 1' IS NEEDED  -->                          
<!-- START BLOCK 1 -->                    
                  <xsl:call-template name="ParaOne"/>
                  <xsl:call-template name="ParaTwo"/>
                  <xsl:call-template name="ParaThree"/>
<!-- END BLOCK 1 -->                    

<!--        UNDER EACH 'First_Collection' THERE CAN BE SEVERAL
'Second_Collections's  -->                          
<!--        AND TO EACH 'Second_Collection' THERE IS ONE
'Bean_Finance'  -->                          

                  <xsl:if
test="Second_Collection/Bean_Finance[product = 3 or product =
4]">
                     <fo:block break-before="page">
                     </fo:block>
                    <xsl:if test="position()=1">
                       <fo:block id="{$toc.two}">
                       </fo:block>
                    </xsl:if>
                  </xsl:if>

                  <xsl:for-each select="Second_Collection">
                     <xsl:if test="Bean_Finance[product = 3 or
product = 4]">
                        <xsl:call-template name="SectionTwo"/>
                     </xsl:if>
                  </xsl:for-each>
                    
                  <fo:block break-before="page">
                  </fo:block>
                 
                  <xsl:if test="position() = 1">
                    <fo:block id="{$toc.three}">
                    </fo:block>
                  </xsl:if>
     
                  <xsl:call-template name="SectionThree"/>
              </xsl:for-each>                      -->
<!-- END OF  FOR-EACH BLOCK WHERE I WOULD ACTUALLY LIKE TO
GENERATE MORE THAN ONE ID  -->
 
              <fo:block id="pgnr.lastPage"/>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
  </xsl:template> 
    
 
<!--==============================================================
========
   !  Section 'generateID'
  
!=================================================================
====-->
              <xsl:template name="GenerateID">
                    <fo:block id="{generate-id()}">
                    </fo:block>
              </xsl:template>
               
 
<!--==============================================================
========
   !  Section 'Coverpage'   with Table of Contents
  
!=================================================================
====-->
  <xsl:template name ="Coverpage">
<!--                          3 Columns    -->
      <fo:table keep-together="always">
        <fo:table-column column-width="50mm"/>
        <fo:table-column column-width="50mm"/>
        <fo:table-column column-width="50mm"/>
        <fo:table-body padding="0mm">

<!--  ROW 1 /  Column 1-2 -->
         <fo:table-row keep-with-next="always"
keep-together="always">
            <fo:table-cell number-columns-spanned="3"
xsl:use-attribute-sets="font-helv10b">
                <fo:block>
                   Table of Contents
                </fo:block>
            </fo:table-cell>
         </fo:table-row>
           
<!--  ROW 2 /  Column 1-2 -->
         <fo:table-row keep-with-next="always"
keep-together="always">
            <fo:table-cell number-columns-spanned="2">
             <fo:block>
             </fo:block>
            </fo:table-cell>
<!--  ROW 2 / Column 3  -->
            <fo:table-cell number-columns-spanned="1"
xsl:use-attribute-sets="font-helv10n">
                <fo:block text-align="center"
text-decoration="underline">
                   Page Number
                </fo:block>
            </fo:table-cell>
         </fo:table-row>
           
<!--    BEGIN OF THE FOR-EACH ROUTINE        -->
<!--                           A REPEATED BLOCK FOR THE TABLE OF
CONTENTS INCLUDING PAGE NUMBERS  -->
  
      <xsl:for-each select="First_Collection">
<!--  ROW 3 /  Column 1-2 -->
         <fo:table-row keep-with-next="always"
keep-together="always">
            <fo:table-cell number-columns-spanned="2"
xsl:use-attribute-sets="font-helv10n">
                <fo:block>
                   - Section One
                </fo:block>
            </fo:table-cell>
<!--  ROW 3 / Column 3  -->
            <fo:table-cell number-columns-spanned="1"
xsl:use-attribute-sets="font-helv10n">
                <fo:block text-align="center">
                     <fo:page-number-citation
ref-id="{generate-id()}"/>
                </fo:block>
            </fo:table-cell>
         </fo:table-row>

<!-- FOR THE MOMENT I'VE HAD TO BIND ROWS 4 & 5 IN AN 'IF TEST
POSITION()=1' ROUTINE, ALTHOUGH WHAT I  -->
<!-- WOULD REALLY LIKE IS THE PAGE NUMBERS FOR ALL OCCURRANCES IF
THERE ARE, AS YOU SEE ABOVE IN ROW 3  -->
<!-- HOW CAN I DO THIS????      -->

       <xsl:if test="position()=1">
<!--  ROW 4 /  Column 1-2 -->
        <xsl:if
test="/section/First_Collection/Second_Collection/Bean_Finance[pro
duct = 3 or product = 4]">
             <fo:table-row keep-with-next="always"
keep-together="always">
                <fo:table-cell number-columns-spanned="2"
xsl:use-attribute-sets="font-helv10n">
                    <fo:block>
                       - Section Two
                    </fo:block>
                </fo:table-cell>
<!--  ROW 4 / Column 3  -->
                <fo:table-cell number-columns-spanned="1"
xsl:use-attribute-sets="font-helv10n">
                    <fo:block text-align="center">
                         <fo:page-number-citation
ref-id="{$toc.two}"/>   
                    </fo:block>
                </fo:table-cell>
             </fo:table-row>
           </xsl:if>
         </xsl:if>

       <xsl:if test="position() = 1">
<!--  ROW 5 /  Column 1-2 -->
         <fo:table-row keep-with-next="always"
keep-together="always">
            <fo:table-cell number-columns-spanned="2"
xsl:use-attribute-sets="font-helv10n">
                <fo:block>
                   - Section Three
                </fo:block>
            </fo:table-cell>
<!--  ROW 5 / Column 3  -->
            <fo:table-cell number-columns-spanned="1"
xsl:use-attribute-sets="font-helv10n">
                <fo:block text-align="center">
                      <fo:page-number-citation
ref-id="{$toc.three}"/>
                </fo:block>
            </fo:table-cell>
         </fo:table-row>
        </xsl:if>

      </xsl:for-each>
<!--    END THE FOR-EACH ROUTINE        -->
        </fo:table-body>
      </fo:table>
  </xsl:template>
</xsl:stylesheet>




OUPUT HOW IT IS NOW

        Table of Contents
                                                    Page Number
        - Section One                                    2
        - Section Two                                    4
        - Section Three                                  7

        - Section One                                    9

OUPUT HOW I WOULD LIKE IT

        Table of Contents
                                                    Page Number
        - Section One                                    2
        - Section Two                                    4
        - Section Three                                  7

        - Section One                                    9
        - Section Two                                   11
        - Section Three                                 13

        (there can be several repeats of these blocks)



Help is really appreciated.
Thanks Kathrin


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



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