Re: [xsl] Pulling xml attributes

Subject: Re: [xsl] Pulling xml attributes
From: "Manfred Staudinger" <manfred.staudinger@xxxxxxxxx>
Date: Thu, 28 Jun 2007 21:24:06 +0200
Hi Luke,

<xsl:for-each select = "tbody/row">
You are selecting row here but in the xml you showed,
row has no child element named "colspec"  so

<xsl:for-each select = "colspec">
does not select anything and therefor you will be missing
the table-column element in your output.

Hope this helps, Manfred


On 28/06/07, Luke Jones <ljones@xxxxxxxxxx> wrote:
XSL Experts,

I have an xml document that contains the tags and attributes I need to
create a table in a pdf document.  I'm using FOP to do this.  The xml
document looks like:

<table>
<tgroup>
<colspec colname="col1" colwidth="2.09" /><colspec align="right"
colname="col2" colwidth="0.82" /><colspec align="right" colname="col3"
colwidth="0.73" /><colspec align="right" colname="col4"
colwidth="0.72" /><colspec align="right" colname="col5"
colwidth="0.67" />
<tbody>
<row>
<entry colsep="0" rowsep="0" />
<entry colsep="0" rowsep="0" />
<entry colsep="0" rowsep="0" />
<entry align="center" colsep="0" rowsep="0">Additional</entry>
<entry colsep="0" rowsep="0" />
</row>
<row>
....
</row
</tbody>
</tgroup>
</table>

I have template that tries to use all of this information to build the
table, and it looks like:

<xsl:template match = "table">
 <xsl:for-each select = "tgroup">
  <xsl:for-each select = "tbody/row">
   <fo:table table-layout = "fixed" width = "100%">
    <xsl:for-each select = "colspec">
     <fo:table-column column-width="{@colwidth}in"/>
    </xsl:for-each>
    <fo:table-body>
     <fo:table-row>
      <xsl:for-each select = "entry">
       <fo:table-cell>
        <fo:block line-height = "16pt" text-decoration="underline"
font-size="10pt">
         <xsl:value-of select = "." />
        </fo:block>
       </fo:table-cell>
      </xsl:for-each>
     </fo:table-row>
    </fo:table-body>
   </fo:table>
  </xsl:for-each>
 </xsl:for-each>
</xsl:template>

However -- it does not appear that the column-width = "{@colwidth}in" is
being recognized, because the size specifications are not being put in
there.  Rather it defaults to a proportional size for all the columns.

Does anyone see where the problem might be occurring?

Thanks!
Luke

Current Thread