[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: make an fo:table with XSLT from an xml file

Subject: RE: make an fo:table with XSLT from an xml file
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Wed, 7 Jul 2004 08:22:24 +0300
xslt row count
Hi,

> here is a sample of my xml file that I want to convert in pdf 
> by using fop.
> 
> <row>
>    <cell>
>        <para column="1" line="1">Session</para>
>    </cell>
>    <cell>
>        <para column="2" line="1">Name</para>
>        <para column="2" line="2">LAP</para>
>    </cell>
> </row>
> 
> the result must be (it is an extract):

Something in the lines of

  <xsl:template match="row">
    <fo:page-sequence master-reference="A4">
      <fo:flow flow-name="xsl-region-body" font-family="sans-serif" font-size="12pt">
        <fo:table border="solid black">
          <fo:table-header text-align="center" font-weight="bold" background-color="silver">
            <xsl:call-template name="row">
              <xsl:with-param name="count">
                <xsl:for-each select="cell/para">
                  <xsl:sort select="@column" data-type="number" order="descending"/>
                  <xsl:if test="position() = 1">
                    <xsl:value-of select="@column"/>
                  </xsl:if>
                </xsl:for-each>
              </xsl:with-param>
            </xsl:call-template>
          </fo:table-header>
        </fo:table>
      </fo:flow>
    </fo:page-sequence>
  </xsl:template>
  <xsl:template name="row">
    <xsl:param name="line" select="1"/>
    <xsl:param name="count" select="0"/>
    <xsl:if test="cell/para[@line = $line]">
      <fo:table-row border-bottom="solid black">
        <xsl:call-template name="col">
          <xsl:with-param name="cells" select="cell/para[@line = $line]"/>
          <xsl:with-param name="count" select="$count"/>
        </xsl:call-template>
      </fo:table-row>
      <xsl:call-template name="row">
        <xsl:with-param name="line" select="$line + 1"/>
        <xsl:with-param name="count" select="$count"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
  <xsl:template name="col">
    <xsl:param name="cells" select="/.."/>
    <xsl:param name="index" select="1"/>
    <xsl:param name="count" select="0"/>
    <xsl:if test="$index &lt;= $count ">
        <fo:table-cell padding="1mm" border-left="solid black">
          <fo:block>
            <xsl:value-of select="$cells[@column = $index]"/>
          </fo:block>
        </fo:table-cell>
      <xsl:call-template name="col">
        <xsl:with-param name="cells" select="$cells"/>
        <xsl:with-param name="index" select="$index + 1"/>
        <xsl:with-param name="count" select="$count"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>

Cheers,

Jarno - Lisa Lashes: Hard Mix

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.