xsl-list
[Top] [All Lists]

[xsl] Overlapping fo:flows

2006-12-29 09:36:51
Dear All:

On 11/15/2006 (archived at:  
www.biglist.com/lists/xsl-list/archives/200611/msg00268.html), I wrote to the 
list about how I would go about creating newspaper-like columns of a long list 
of items.  The majority of the people who helped me suggested that I create the 
newspaper-like columns using fo:flow.  

By "newspaper columns," I mean that I would like the data to stream from one 
column to the other before breaking onto a new page.  In the past, I tried to 
create the two columns using table coding, however, when doing this, the list 
of elements in the first column continued onto the next page, instead of 
streaming onto the second column first.

The newspaper columns are supposed to be created in the first couple pages of 
the document using the header, footer and beginning of document "banner" (a 
graphical bar indicating the chapter name) of the document body.  For example:

header
graphical banner
newspaper columns
rest of document
footer

A portion of the XML from which I want to build the columns is:

<characterPositions>
         <characterPosition type="full concise">
            <label>18-19</label>
            <name>Form of composition</name>
            <level>standard</level>
            <value type="concise">
               <label>an</label>
               <name>Anthems</name>
               <level>standard</level>
            </value>
            <value type="concise">
               <label>bd</label>
               <name>Ballads</name>
               <level>standard</level>
            </value>
<!-- There are many, many, many more <value> elements within this 
<characterPosition> element -->
    </characterPosition>
</characterPositions>

A portion of my XSL-FO coding is:

<xsl:template match="/">
    
  <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format";
   xmlns:rx="http://www.renderx.com/XSL/Extensions";>
  
  <fo:layout-master-set>
   
   <fo:simple-page-master
             master-name="even_page" 
             page-height="11in" 
             margin-right="1in"
             margin-top=".5in" 
            margin-left="1in" 
            margin-bottom=".5in" 
            page-width="8.5in">
    <fo:region-body 
           margin-top=".3in" 
           margin-bottom=".3in"/>
    <fo:region-before 
           extent="8.5in" 
           region-name="even_before"/>
    <fo:region-after 
          extent=".2in" 
          precedence="true" 
          region-name="even_after"/>
   </fo:simple-page-master>
   
   <fo:simple-page-master 
       master-name="odd_page" 
       page-height="11in" 
       margin-right="1in"
       margin-top=".5in" 
       margin-left="1in" 
       margin-bottom=".5in" 
       page-width="8.5in">
    <fo:region-body 
       margin-top=".3in" 
       margin-bottom=".3in"/>
    <fo:region-before 
       extent="8.5in" 
       region-name="odd_before"/>
    <fo:region-after 
       extent=".2in" 
       precedence="true" 
       region-name="odd_after"/>
   </fo:simple-page-master>
   
   <fo:simple-page-master   
      master-name="TwoColumns">
    <fo:region-body  
       column-count="2"
       column-gap="0.2in"
       border-top="thin solid silver"
       border-bottom="thin solid silver"
       margin="0.9in 0.4in"/>
    <fo:region-before
       extent="0.8in"
       display-align="after"
       padding="0in 0.4in 3pt"/>
    <fo:region-after 
       extent="0.8in"
       display-align="before"
       padding="0.1in 0.4in 0in"/>
   </fo:simple-page-master>
   
   <fo:page-sequence-master master-name="Repeat-TwoColumns">
    <fo:repeatable-page-master-reference master-                    
         reference="TwoColumns"/>
   </fo:page-sequence-master>
   
   <fo:page-sequence-master master-name="Page">
    <fo:repeatable-page-master-alternatives>
     <fo:conditional-page-master-reference 
        master-reference="odd_page" 
        odd-or-even="odd"
        page-position="any"/>
     <fo:conditional-page-master-reference 
        master-reference="even_page" 
        odd-or-even="even"
        page-position="any"/>
    </fo:repeatable-page-master-alternatives>
   </fo:page-sequence-master>
  </fo:layout-master-set>
   
   <fo:page-sequence 
         master-reference="Repeat-TwoColumns">
    <fo:flow flow-name="xsl-region-body">
     <fo:block font-size="10pt">
      <xsl:apply-templates select="field/guidelines/characterPositions"  
       mode="header"/>
     </fo:block>
    </fo:flow>
   </fo:page-sequence>
   
   <fo:page-sequence 
     master-reference="Page" 
     force-page-count="even" 
     initial-page-number="1">
   
   <fo:static-content 
      flow-name="odd_before">
    <fo:block 
       text-align="right" 
       font-weight="bold" 
       font-size="14pt">008 - Music</fo:block>
   </fo:static-content>
   
   <fo:static-content 
      flow-name="odd_after">
    <fo:block>
     <fo:inline 
        text-align-last="justify" 
        font-style="italic" 
        font-size="10pt">MARC 21 - Bibliographic
      <fo:leader 
         leader-pattern="space" 
         leader-length="25%"/>October 2006
      <fo:leader 
         leader-pattern="space" 
         leader-length="20%"/>008 - Music - p.<fo:page-number/>
     </fo:inline>
    </fo:block>
   </fo:static-content>
   
   <fo:static-content 
      flow-name="even_before">
    <fo:block 
       text-align="left" 
       font-weight="bold" 
       font-size="14pt">008 - Music</fo:block>
   </fo:static-content>
   
   <fo:static-content 
      flow-name="even_after">
    <fo:block>
     <fo:inline 
        text-align-last="justify" 
        font-style="italic" 
        font-size="10pt">008 - Music - p.<fo:page-number/>
      <fo:leader 
         leader-pattern="space" 
         leader-length="25%"/>October 2006
      <fo:leader 
         leader-pattern="space" 
         leader-length="25%"/>MARC 21 - Bibliographic</fo:inline>
    </fo:block>
   </fo:static-content> 
    
    <fo:flow 
      flow-name="xsl-region-body">
    <fo:block 
     font-size="10pt">
     <xsl:apply-templates/>
    </fo:block>
   </fo:flow>
   
   </fo:page-sequence> 
  
  </fo:root>
  
 </xsl:template>

The XSL-FO that I reference in the Repeat-TwoColumns flow is:

<xsl:template match="characterPositions" mode="header">
  <fo:block space-before="2em">
   <fo:table table-layout="fixed" width="100%">
    <fo:table-column column-width="100em"/>
    <fo:table-body>
     <fo:table-row>
      <fo:table-cell>
       <fo:block font-weight="bold">
        <xsl:text>Character Positions (008/18-34 and 006/01-17)</xsl:text>
       </fo:block>
      </fo:table-cell>
     </fo:table-row>
    </fo:table-body>
   </fo:table>
   <xsl:variable name="characterPositionCount" select="count(characterPosition) 
div 2+1"/>
   <fo:table table-layout="fixed" width="100%">
    <fo:table-column column-width="27em"/>
    <fo:table-column column-width="60em"/>
    <fo:table-body>
     <fo:table-row>   
      <fo:table-cell>
       <fo:block>        
        <fo:table table-layout="fixed" width="40%">
         <fo:table-column column-width="5em"/>
         <fo:table-column column-width="15em"/>
         <fo:table-column column-width="15em"/>
         <fo:table-column column-width="5em"/>
         <fo:table-body>
          <xsl:for-each 
select="characterPosition[position()&lt;$characterPositionCount]"> 
           <fo:table-row>   
            <fo:table-cell>
               <fo:block text-align="left" margin-left="1em">
                <xsl:value-of select="label"/>
               </fo:block>
            </fo:table-cell>
            <fo:table-cell>    
               <fo:block text-align="left">
                <xsl:value-of select="name"/>
               </fo:block>
            </fo:table-cell>
           </fo:table-row>
           <fo:table-row>
            <fo:table-cell>
             <xsl:for-each select="value">
              <fo:block margin-left="3em">
               <xsl:value-of select="label"/>
              </fo:block>
             </xsl:for-each>
            </fo:table-cell>
            <fo:table-cell>
             <xsl:for-each select="value">
              <fo:block>
               <xsl:value-of select="name"/>
              </fo:block>
             </xsl:for-each>
            </fo:table-cell>
           </fo:table-row>
          </xsl:for-each>
         </fo:table-body>
        </fo:table>
       </fo:block>
      </fo:table-cell>
      <fo:table-cell>
       <fo:block>
        <fo:table table-layout="fixed" width="40%">
         <fo:table-column column-width="5em"/>
         <fo:table-column column-width="15em"/>
         <fo:table-column column-width="15em"/>
         <fo:table-column column-width="5em"/>
         <fo:table-body>
          <xsl:for-each 
select="characterPosition[position()&gt;$characterPositionCount]"> 
           <fo:table-row>   
            <fo:table-cell>
               <fo:block text-align="left" margin-left="1em">
                <xsl:value-of select="label"/>
               </fo:block>  
            </fo:table-cell>
            <fo:table-cell>     
               <fo:block text-align="left">
                <xsl:value-of select="name"/>
               </fo:block>
            </fo:table-cell>
           </fo:table-row>
           <fo:table-row>
            <fo:table-cell>
             <xsl:for-each select="value">
              <fo:block margin-left="3em">
               <xsl:value-of select="label"/>
              </fo:block>
             </xsl:for-each>
            </fo:table-cell>
            <fo:table-cell>
             <xsl:for-each select="value">
              <fo:block>
               <xsl:value-of select="name"/>
              </fo:block>
             </xsl:for-each>
            </fo:table-cell> 
           </fo:table-row>
          </xsl:for-each>
         </fo:table-body>
        </fo:table>
       </fo:block>
      </fo:table-cell>
     </fo:table-row>
    </fo:table-body>
   </fo:table>
   </fo:block>
  <fo:block>
   <fo:leader leader-length="100%" leader-pattern="rule" rule-style="solid" 
rule-thickness=".1mm" color="black"/>   
  </fo:block> 
  </xsl:template> 

Using the above XSL-FO, I output the newspaper columns at the beginning of the 
document (which is what I want), however, the columns do not contain the 
graphical banner or the header and footer of the document.

I would like to "overlap" or "overlay" (I am not sure what the terminology is 
for this) the "Repeat-TwoColumns" flow with the "Page" flow.  For example:

Page flow for the header, footer, and document banner
Repeat-TwoColumns flow for the newspaper columns
Page flow for the rest of the document.

I have tried many, many different ways to code the above with no luck.  I have 
also endlessly searched this list's archives and consulted  two XML and XSL-FO 
publications.

At the advice of a colleague, I once tried using the XEP extension: 
<rx:flow-section>.  For example:

 <rx:flow-section column-count="2" column-gap="8pt">
      <fo:block font-size="10pt">
       <xsl:apply-templates select="field/guidelines/characterPositions" 
mode="header"/>
      </fo:block>
     </rx:flow-section> 

However, another colleague told me that I could create the columns without 
using the extension.

Could someone please help me figure out how to overlap the two fo:flows so that 
I can create the newspaper-like columns, along with the rest of the document.

I am using XSLT 1.0 and XPATH 1.0 with XEP.

Thank you very much for all of your help!  I sincerely appreciate it!

Best wishes,





Jackie Radebaugh

Library of Congress
Network Development & MARC Standards Office
Washington, DC
USA
Phone:  +1-202-707-1153
FAX:  +1-202-707-0115
E-Mail:  jrad(_at_)loc(_dot_)gov


--~------------------------------------------------------------------
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>
  • [xsl] Overlapping fo:flows, Jacqueline Radebaugh <=