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

Re: Column widths

Subject: Re: Column widths
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Sun, 23 Jun 2002 11:40:49 +0200
table col width
Hello Gustaf,

here is a solution that works for me:

<xsl:template match="tr">
    <xsl:apply-templates select="td|th"/>

<xsl:template match="td|th">
  <xsl:variable name="x" select="position()"/>
    <xsl:copy-of select="(ancestor::table/colgroup/col)[$x]/@width"/>

The correct applying the template on td and th is important for a correct position(). The next step is the "grouping" of the col-elements. Because they have different colgroup-parents, you must use parentheses for this job. This should work.

Two more comments: Why are you using the attribute-axis, writing @ is much shorter ... and in my eyes more readable. And have a look at <xsl:copy-of/> above. It does the same job like your <xsl:if/> + <xsl:attribute/> + <xsl:value-of/>. If a attribute should have the same name and value in input and output, it will be easier to copy it.


<fo:table-cell width="30%" xmlns:fo="test">
  <fo:block>A header</fo:block>
<fo:table-cell width="60%" xmlns:fo="test">
  <fo:block>Some content here.</fo:block>
<fo:table-cell width="10%" xmlns:fo="test">
  <fo:block>Some more here.</fo:block>



Gustaf Liljegren wrote:
Mike Brown wrote:

Brackets indicate predicates. Think of them as filters, providing everything
to the left of them, for which everything inside them is true.

Got it.

Okay, here's a sample table:

    <col width="30%"/>
    <col width="60%"/>
    <col width="10%"/>
      <th>A header</th>
      <td>Some content here.</td>
      <td>Some more here.</td>

For now, I assume there will always be equal amounts of table cells in a
row as there are <col> elements. The result will look like this:

      <fo:table-cell width="30%">...</fo:table-cell>
      <fo:table-cell width="60%">...</fo:table-cell>
      <fo:table-cell width="10%">...</fo:table-cell>

Here's how the <td> template looks like. The problem is in the long XPath

<xsl:template match="td">
<xsl:variable name="x" select="position()"/>
<fo:table-cell xsl:use-attribute-sets="table-padding">
<xsl:if test="ancestor::table//col[$x]/attribute::width">
<xsl:attribute name="width">
<xsl:value-of select="ancestor::table//col[$x]/attribute::width"/>

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

Current Thread


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.
First Name
Last Name
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.