Click to See Complete Forum and Search --> : XSL-FO Display data in Table format


vikram1784
December 5th, 2008, 06:48 AM
XML file

<Report>
<headers>
<header id="c0" type="string">
<name>Type</name>
<label>Type</label>
</header>
<header id="c1" type="string">
<name>Name</name>
<label>Name</label>
</header>
<header id="c2" type="string">
<name>Rev</name>
<label>Revision</label>
<header id="c3" type="string">
<name>Desc</name>
<label>Description</label>
</header>

<objects>
<row type="Woven" name="0000001" rev="1" current="Initiated" policy="Raw Material" symbolicType="type_Woven">
<cell index="0" colRef="c0">
<value>Woven</value>
</cell>
<cell index="1" colRef="c1">
<value>0000001</value>
</cell>
<cell index="2" colRef="c2">
<value>1</value>
</cell>
<cell index="3" colRef="c3">
<value>DeDescription</value>
</cell>
<cell index="4" colRef="c4">
<value>Initiated</value>
</cell>
</row>
</objects>
</Report>

Output should be in format:
Type : Woven Name : 0000001
Revision : 1 Status :Initiated

XSL:

<fo:table width="25%" border="0pt solid gray" padding="3pt">
<fo:table-column/>
<fo:table-body>
<xsl:for-each select="./headers/header">
<fo:table-row >
<xsl:if test="position() mod 2 = 1">
<xsl:attribute name="background-color">#dddecb</xsl:attribute>
<fo:table-cell xsl:use-attribute-sets="tableCell">
<fo:block font-weight="bold" font-family="Verdana-Bold" font-size="15pt">
<xsl:value-of select="label"/>
</fo:block>
</fo:table-cell>
</xsl:if>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
<xsl:template name="create-value-odd-tab">
<fo:table width="25%" border="0pt solid gray" padding="3pt">
<fo:table-column/>
<fo:table-body>
<xsl:for-each select="./objects/row/cell">
<fo:table-row >
<xsl:if test="position() mod 2 = 1">
<xsl:attribute name="background-color">#eeeeee</xsl:attribute>
<fo:table-cell xsl:use-attribute-sets="tableCell">
<fo:block font-weight="bold" font-family="Verdana-Bold" font-size="15pt">
<xsl:value-of select="value"/>
</fo:block>
</fo:table-cell>
</xsl:if>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</xsl:template>
two more tables to shoow even entries..


To represent the data in XML in above format i am creating 4 different tables.
I basically want the header and value format data output but it should display two fields on the same row.

How wud is be possible using single table? or any other alternative way?

Thanks In Advance!
Vikram

vikram1784
December 5th, 2008, 09:10 AM
Is it possible to iterate on two nodes? like inside headers for loop can I have for loop on objects node? I tried it but didnt succeed