Loading ...
Sorry, an error occurred while loading the content.

Re: [XSL-FO] Re: Text divided into several columns?

Expand Messages
  • Douglas Lovell
    You wouldn t use XSLT elements inside of FO. You will use XSLT to generate FO. Your XML data + XSLT stylesheet = FO result document. The following sample
    Message 1 of 4 , Oct 1, 2002
    • 0 Attachment
      You wouldn't use XSLT elements inside of FO. You will use XSLT to generate
      FO. Your XML data + XSLT stylesheet = FO result document.

      The following sample source and stylesheet demonstrate column-ordered
      output into a table. This will deprive you of the fun of solving the
      puzzle for yourself.

      Here is some sample input data. Provide this as the XML data input to the
      formatter:
      <?xml version="1.0"?>
      <data>
      <item>Peter</item>
      <item>Piper</item>
      <item>picked</item>
      <item>a</item>
      <item>peck</item>
      <item>of</item>
      <item>pickled</item>
      <item>peppers.</item>
      <item>How</item>
      <item>many</item>
      <item>peppers</item>
      <item>did</item>
      <item>Peter</item>
      <item>Piper</item>
      <item>pick?</item>
      </data>

      The following stylesheet formats the above data into three columns, in
      column order. Provide it as the XSLT stylesheet input to a table-capable
      formatter:
      <?xml version='1.0'?>
      <xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:fo="http://www.w3.org/1999/XSL/Format">

      <xsl:strip-space elements="*"/>

      <xsl:template match="/">
      <fo:root>
      <fo:layout-master-set>
      <fo:simple-page-master
      master-name="page">
      <fo:region-body
      region-name="body"
      margin-top="0.5in"
      margin-bottom="1in"
      margin-left="0.5in"
      margin-right="0.5in"/>
      </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="page">
      <fo:flow flow-name="body">
      <xsl:apply-templates/>
      </fo:flow>
      </fo:page-sequence>
      </fo:root>
      </xsl:template>

      <xsl:template match="data">
      <xsl:variable name="ctRows">
      <xsl:value-of select="ceiling(count(*) div 3)"/>
      </xsl:variable>
      <fo:table>
      <fo:table-column column-width="4pc"/>
      <fo:table-column column-width="6pc"/>
      <fo:table-column column-width="12pc"/>
      <fo:table-body>
      <xsl:apply-templates>
      <xsl:sort
      select="floor((position()-1) div $ctRows) + ((position()-1) mod $ctRows) * 3"
      data-type="number"/>
      </xsl:apply-templates>
      </fo:table-body>
      </fo:table>
      </xsl:template>

      <xsl:template match="item">
      <fo:table-cell>
      <xsl:if test="(position()-1) mod 3 = 2">
      <xsl:attribute name="ends-row">yes</xsl:attribute>
      </xsl:if>
      <fo:block>
      <xsl:apply-templates/>
      </fo:block>
      </fo:table-cell>
      </xsl:template>

      </xsl:stylesheet>

      Douglas Lovell




      "dennis_joel_david"
      <dennis.myren@greyinte To: XSL-FO@yahoogroups.com
      ractive.no> cc:
      Subject: [XSL-FO] Re: Text divided
      10/01/2002 10:15 AM into several columns?
      Please respond to
      XSL-FO





      Hi.
      Do you know if it is possible to use XSLT elements inside a FO
      document that will be processed by FOP 0.20.4 ?
      I have tried, without success.
      And if so, the XSLT tricks you were talking about, can you give me
      an example of that?
      Thank You
      Dennis


      >You may
      > be able to use XSLT counting tricks to "flow" the content from one
      table
      > column to the next. That depends on the structure of your input
      and other
      > specific details of your expected result.
      > Douglas Lovell
    Your message has been successfully submitted and would be delivered to recipients shortly.