[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] fun with fo tab formatting


Subject: RE: [xsl] fun with fo tab formatting
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Mon, 15 Dec 2003 23:48:57 +0100

> -----Original Message-----
> From: Kyle Partridge
>
> Don't mean to be a pest, but can anyone help with this??  I can't seem
> to get this working...
>
<snip />
>
> First, it won't let me save this, because it doesn't like me opening
> tags in one statement and closing them in another...

That seems --desirable, in most cases. Meaning: basically, if you run into
situations like this, where you're starting and ending elements in different
nodes, that's almost a guarantee there is _something_ icky about the
design...

> <xsl:template match="ws:tab">
>   <xsl:if test="position()=1">
>	<fo:table>
>	  <fo:table-body>
>	    <fo:table-row>
>   </xsl:if>

No, no, no... gathering from your original post, what you want is something
like :

<xsl:template match="ws:p">

  <fo:table layout="fixed" width="100%">
    <!-- columns... -->
    <!-- practical way to do it in this case, would be to match    -->
    <!-- the first br and create a column for every preceding tab  -->
    <!-- use a moded template for clarity                          -->
    <xsl:apply-templates select="br[1]" mode="colcreate" />

    <fo:table-body>
      <xsl:apply-templates select="br" mode="rowcreate" />
    </fo:table-body>
  </fo:table>

</xsl:template>

<xsl:template match="br" mode="colcreate">

  <xsl:variable name="cols" select="count(preceding-sibling::tab)" />
  <xsl:for-each select="preceding-sibling::tab">
    <fo:table-column column-width="proportional-column-width({$cols})" />
  </xsl:for-each>

</xsl:template>

<xsl:template match="br" mode="rowcreate">

  <xsl:variable name="cols" select="count(preceding-sibling::tab)" />

  <fo:table-row>
    <xsl:for-each select="preceding-sibling::tab[position() &lt;= $cols]">
      <fo:table-cell>
        <xsl:value-of select="following-sibling::text()[1]" />
      </fo:table-cell>
    </xsl:for-each>
  </fo:table-row>

</xsl:template>

> Second...I've reached a wall with my new "get-width" template:

If I guess correctly, you won't be needing this...?


Hope this helps!

Cheers,

Andreas


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



Current Thread