xsl-list
[Top] [All Lists]

Re: [xsl] XSL FO Table formatting

2006-12-13 10:18:08
If you can, change your XML to something like:

<row>
<DscA>1. Money</DscA>
<DscA>3,000.00</DscA>
<DscA>0.00</DscA>
</row>
<row>
<DscA>2. Money</DscA>
<DscB>3,000.00</DscB>
<DscB>0.00</DscB>
</row>
<row>
<DscB>3. Others</DscB>
<DscB>10,000.00</DscB>
<DscB>0.00</DscB>
</row>

and then change your xsl to something like:

<xsl:for-each select="//row">
<fo:table-row line-height="13pt">
<xsl:for-each select="DscA | DscB">
<fo:table-cell border-width="1pt" border-style="solid">
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</fo:table-cell>
</xsl:for-each>
</fo:table-row>
</xsl:for-each>


or, if you can't change the XML and it is always the same number of cells 
in a row, you can try using position() and mod to break your data up.  It 
would look something like (this breaks lists of data into 4 columns going 
down then across so it is not exactly what you want but it may help):

<xsl:for-each select="line[position() mod 4 = 1]">
        <fo:table-row>
        <xsl:for-each select=".|following-sibling::line[position() &lt; 
4]">
                <fo:table-cell padding="1pt">
                        <fo:block text-align="center">
                        <snip/>
-Lou

"CyberSpace Industries 2000 Inc." <csi2000(_at_)urbanmarket(_dot_)com> wrote on 
12/13/2006 11:46:45 AM:

The reason you get what you do is that there is nothing in your xml to 
denote what a "row" is.. and nothing in your xslt to denote that either.

I believe that <xsl:for-each select="//DscA | //DscB">
will iterate over the 9 nodes selected and output a single cell in a 
single 
row for each.

Are you able to add the intelligence for "row" to your input XML?

Cheers...Hugh
CyberSpace Industries 2000 Inc.
XML Training and Consulting

----- Original Message ----- 
From: "Dave Dran" <davedran(_at_)gmail(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Wednesday, December 13, 2006 11:18 AM
Subject: [xsl] XSL FO Table formatting


XSL FO Table formatting



--------------------------------------------------------------------------------

Hi!

Help, I think there is a simple solution for this. Can't seem to
format this correctly

Thanks alot.

Dave

<fo:table width="100%">
<fo:table-column column-width="proportional-column-width(50)"/>
<fo:table-column column-width="proportional-column-width(25)"/>
<fo:table-column column-width="proportional-column-width(25)"/>
<fo:table-body>
<xsl:for-each select="//DscA | //DscB">
<fo:table-row line-height="13pt">
<fo:table-cell border-width="1pt" border-style="solid">
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>

Actual XML Data
<DscA>1. Money</DscA>
<DscA>3,000.00</DscA>
<DscA>0.00</DscA>
<DscA>2. Money</DscA>
<DscB>3,000.00</DscB>
<DscB>0.00</DscB>
<DscB>3. Others</DscB>
<DscB>10,000.00</DscB>
<DscB>0.00</DscB>

The expected output (3 columns)

1. Money 3,000.00 0.00
2. Money 3,000.00 0.00
3. Others 10,000.00 0.00

The current output

1. Money
3,000.00
0.00
2. Money
3,000.00
0.00
3. Others
10,000.00
0.00
TOTAL

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>