- From: anandhthiyagarajan <anandhthiyagarajan@gmail.com>
- Date: Wed, 3 Feb 2010 21:51:26 -0800 (PST)
- To: www-xsl-fo@w3.org
Okay i will make you clear.
Consider the xml
<node>
<title>
<ingredients>
<name>Category</name>
<name>Noodles</name>
<name>Pizza</name>
</ingredients>
<ingredients>
<ingredient>
<content>Fat</content>
<description>aaaa</description>
</ingredient>
</ingredients>
<ingredients>
<ingredient>
<content>Fat</content>
<description>hgjhgk</description>
</ingredient>
</ingredients>
</title>
</node>
Consider the xsl:fo
<xsl:template match="node/title">
<fo:block space-before="4mm" hyphenate="true">
<fo:table table-layout="fixed" width="7in">
<xsl:for-each select="ingredients/name">
<fo:table-column column-width="10pt" />
</xsl:for-each>
<fo:table-header hyphenate="true">
<xsl:for-each select="head">
<fo:table-row>
<xsl:for-each select="ingredients/name">
<fo:table-cell border="thin black ridge"
padding="4pt" font-size="10pt" letter-spacing="0.8pt" color="white"
background-color="rgb(39,64,139)"
font-weight="bold" font-family="Verdana"
text-align="center">
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</fo:table-cell>
</xsl:for-each>
</fo:table-row>
</xsl:for-each>
</fo:table-header>
<fo:table-body hyphenate="true">
<xsl:for-each select="row">
<fo:table-row>
<xsl:for-each select="ingredients/ingredient">
<fo:table-cell border="thin black ridge"
padding="4pt" font-size="10pt" color="black"
letter-spacing="1pt" font-family="Verdana"
text-align="center">
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</fo:table-cell>
</xsl:for-each>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:block>
</xsl:template>
I am attaching the output file
http://old.nabble.com/file/p27448047/Table.doc Table.doc
Hope this would be clear.
Thanks
Anandh
Aish wrote:
>
> Hi Anandh,
>
> I am unable to understand your question.
>
> 1. Did you mean wrapping text in fo:table?
> If the case is so, you can mention the width of each cell by the
> property fo:table-column column-width(<fo:table-column
> column-width="1in"/>) of the table. This is an inbuilt wrapping of text.
> In case if you need to hyphenate words, you can use hyphenation property.
> Check out the site
> http://www.cafeconleche.org/books/bible3/chapters/ch16.html for
> explanation regarding that property.
>
> 2. Did you mean size of table?
> If the case is so, you can mention the width of the table using the
> property "width". For eg:<fo:table table-layout="fixed" width="100%"
> font-size="9pt">
>
> Hope this helps. Let me know if you need any further clarifications
>
> Regards
> Aish
>
>
> anandhthiyagarajan wrote:
>>
>> Thanks a lot aish. It served exactly my purpose. Can you also suggest me
>> is it possible to wrap the table in xsl:fo.
>>
>>
>>
>> Thanks again
>>
>> Anandh
>>
>> Aish wrote:
>>>
>>> Hi Anandh,
>>>
>>> I did it using FOP 0.95. In your xsl code, number of <fo:table-column
>>> column-width="1in"/> doesn't match(less than) the columns given under
>>> for-each of quarters and hence the problem. You need to check empty
>>> quarters. Also, attribute "increment-by" is removed as it doesn't
>>> support. The code will be as below.
>>>
>>> <xsl:template match="root/roadmap">
>>> <fo:block space-before='2mm'>
>>> <fo:block font-size="10pt" color="black" font-weight="bold"
>>> space-before="0.54in" space-after="2pt" >
>>> ROADMAP INFORMATION
>>> </fo:block>
>>> <fo:block space-before='2mm'>
>>> </fo:block>
>>> <fo:table border-collapse="collapse" font-size="9pt">
>>> <fo:table-column column-width="1in"/>
>>> <fo:table-column column-width="1in"/>
>>> <fo:table-column column-width="1in"/>
>>> <fo:table-column column-width="1in"/>
>>> <fo:table-column column-width="1in"/>
>>> <fo:table-header color="black" background-color="rgb(39,64,139)"
>>> font-weight="bold">
>>> <fo:table-row>
>>> <fo:table-cell padding="2pt" border="1pt solid black"
>>> text-align="center">
>>> <fo:block>YEAR</fo:block>
>>> </fo:table-cell>
>>> <fo:table-cell padding="2pt" border="1pt solid black"
>>> text-align="center">
>>> <fo:block>Q1</fo:block>
>>> </fo:table-cell>
>>> <fo:table-cell padding="2pt" border="1pt solid black"
>>> text-align="center">
>>> <fo:block>Q2</fo:block>
>>> </fo:table-cell>
>>> <fo:table-cell padding="2pt" border="1pt solid black"
>>> text-align="center">
>>> <fo:block>Q3</fo:block>
>>> </fo:table-cell>
>>> <fo:table-cell padding="2pt" border="1pt solid black"
>>> text-align="center">
>>> <fo:block>Q4</fo:block>
>>> </fo:table-cell>
>>> </fo:table-row>
>>> </fo:table-header>
>>> <fo:table-body>
>>> <xsl:for-each select="years">
>>> <fo:table-row>
>>> <fo:table-cell padding="2pt" border="1pt solid black"
>>> background-color="rgb(255,255,255)" text-align="center">
>>> <fo:block><xsl:value-of select="year"/></fo:block>
>>> </fo:table-cell>
>>> <xsl:variable name="MyQuarter"><xsl:value-of
>>> select="quarters[1]/quarter"/></xsl:variable>
>>> <xsl:choose>
>>> <xsl:when test="$MyQuarter='Q1'">
>>>
>>> </xsl:when>
>>> <xsl:when test="$MyQuarter='Q2'">
>>> <fo:table-cell padding="2pt" border="1pt solid
>>> black"><fo:block/></fo:table-cell>
>>> </xsl:when>
>>> <xsl:when test="$MyQuarter='Q3'">
>>> <fo:table-cell padding="2pt" border="1pt solid
>>> black" text-align="center"><fo:block/></fo:table-cell>
>>> <fo:table-cell padding="2pt" border="1pt solid
>>> black" text-align="center"><fo:block/></fo:table-cell>
>>> </xsl:when>
>>> <xsl:when test="$MyQuarter='Q4'">
>>> <fo:table-cell padding="2pt" border="1pt solid
>>> black" text-align="center"><fo:block/></fo:table-cell>
>>> <fo:table-cell padding="2pt" border="1pt solid
>>> black" text-align="center"><fo:block/></fo:table-cell>
>>> <fo:table-cell padding="2pt" border="1pt solid
>>> black" text-align="center"><fo:block/></fo:table-cell>
>>> </xsl:when>
>>> <xsl:when test="$MyQuarter='Q5'">
>>> <fo:table-cell padding="2pt" border="1pt solid
>>> black" text-align="center"><fo:block/></fo:table-cell>
>>> <fo:table-cell padding="2pt" border="1pt solid
>>> black" text-align="center"><fo:block/></fo:table-cell>
>>> <fo:table-cell padding="2pt" border="1pt solid
>>> black" text-align="center"><fo:block/></fo:table-cell>
>>> <fo:table-cell padding="2pt" border="1pt solid
>>> black" text-align="center"><fo:block/></fo:table-cell>
>>> </xsl:when>
>>> </xsl:choose>
>>> <xsl:for-each select="quarters">
>>> <fo:table-cell padding="2pt" border="1pt solid black"
>>> background-color="rgb(255,255,255)" text-align="center">
>>> <fo:block><xsl:apply-templates
>>> select="requirements"/></fo:block>
>>> </fo:table-cell>
>>> </xsl:for-each>
>>> </fo:table-row>
>>> </xsl:for-each>
>>> </fo:table-body>
>>> </fo:table>
>>> </fo:block>
>>> </xsl:template>
>>>
>>> <xsl:template match="requirements">
>>> <xsl:apply-templates/>
>>> </xsl:template>
>>>
>>> <xsl:template match="requirement">
>>> <xsl:apply-templates/>
>>> </xsl:template>
>>>
>>> This code will produce your desired output with FOP 0.95. Hope this
>>> helps:-)
>>>
>>> Regards
>>> Aish
>>>
>>>
>>> anandhthiyagarajan wrote:
>>>>
>>>> Hi everybody
>>>>
>>>> I am stuck up with an issue in manipulating the table.
>>>>
>>>>
>>>>
>>>> Consider the below XML and XSL
>>>>
>>>> <root>
>>>> <roadmap>
>>>> <years>
>>>> <year>2009</year>
>>>> <quarters>
>>>> <quarter>Q3</quarter>
>>>> <requirements>
>>>> <requirement>Mp3Player</requirement>
>>>> </requirements>
>>>> <requirements>
>>>> <requirement>Mp3Player</requirement>
>>>> </requirements>
>>>> <requirements>
>>>> <requirement>DataCable</requirement>
>>>> </requirements>
>>>> <requirements>
>>>> <requirement>Mp3Player</requirement>
>>>> </requirements>
>>>> <requirements>
>>>> <requirement>Mp3Player</requirement>
>>>> </requirements>
>>>> <requirements>
>>>> <requirement>Bluetooth</requirement>
>>>> </requirements>
>>>> </quarters>
>>>> <quarters>
>>>> <quarter>Q4</quarter>
>>>> <requirements>
>>>> <requirement>DataCable</requirement>
>>>> </requirements>
>>>> <requirements>
>>>> <requirement>MemoryCard</requirement>
>>>> </requirements>
>>>> <requirements>
>>>> <requirement>InbuiltCam</requirement>
>>>> </requirements>
>>>> </quarters>
>>>> </years>
>>>> </roadmap>
>>>> </root>
>>>>
>>>>
>>>> XSL:
>>>>
>>>> <xsl:template match="root/roadmap">
>>>> <fo:block space-before='2mm'>
>>>> <fo:block font-size="10pt" color="black" font-weight="bold"
>>>> increment-by="1.1.1" space-before="0.54in" space-after="2pt" >
>>>> ROADMAP INFORMATION
>>>> </fo:block>
>>>> <fo:block space-before='2mm'>
>>>> </fo:block>
>>>> <fo:table border-collapse="collapse" font-size="9pt">
>>>> <fo:table-column column-width="1in"/>
>>>> <fo:table-column column-width="50%"/>
>>>> <fo:table-column column-width="50%"/>
>>>> <fo:table-column column-width="50%"/>
>>>> <fo:table-column column-width="50%"/>
>>>> <fo:table-header color="black"
>>>> background-color="rgb(39,64,139)"
>>>> font-weight="bold">
>>>> <fo:table-row>
>>>> <fo:table-cell padding="2pt" border="1pt solid black"
>>>> text-align="center">
>>>> <fo:block>YEAR</fo:block>
>>>> </fo:table-cell>
>>>> <fo:table-cell padding="2pt" border="1pt solid black"
>>>> text-align="center">
>>>> <fo:block>Q1</fo:block>
>>>> </fo:table-cell>
>>>> <fo:table-cell padding="2pt" border="1pt solid black"
>>>> text-align="center">
>>>> <fo:block>Q2</fo:block>
>>>> </fo:table-cell>
>>>> <fo:table-cell padding="2pt" border="1pt solid black"
>>>> text-align="center">
>>>> <fo:block>Q3</fo:block>
>>>> </fo:table-cell>
>>>> <fo:table-cell padding="2pt" border="1pt solid black"
>>>> text-align="center">
>>>> <fo:block>Q4</fo:block>
>>>> </fo:table-cell>
>>>> </fo:table-row>
>>>> </fo:table-header>
>>>> <fo:table-body>
>>>> <xsl:for-each select="years">
>>>> <fo:table-row>
>>>> <fo:table-cell padding="2pt" border="1pt solid black"
>>>> background-color="rgb(255,255,255)" text-align="center">
>>>> <fo:block><xsl:value-of select="year"/></fo:block>
>>>> </fo:table-cell>
>>>> <xsl:for-each select="quarters">
>>>> <fo:table-cell padding="2pt" border="1pt solid black"
>>>> background-color="rgb(255,255,255)" text-align="center">
>>>> <fo:block><xsl:value-of select="."/></fo:block>
>>>> </fo:table-cell>
>>>> <fo:table-cell padding="2pt" border="1pt solid black"
>>>> background-color="rgb(255,255,255)" text-align="center">
>>>> <fo:block><xsl:value-of
>>>> select="requirement"/></fo:block>
>>>> </fo:table-cell>
>>>> <fo:table-cell padding="2pt" border="1pt solid black"
>>>> background-color="rgb(255,255,255)" text-align="center">
>>>> <fo:block><xsl:value-of
>>>> select="requirement"/></fo:block>
>>>> </fo:table-cell>
>>>> <fo:table-cell padding="2pt" border="1pt solid black"
>>>> background-color="rgb(255,255,255)" text-align="center">
>>>> <fo:block><xsl:value-of
>>>> select="requirement"/></fo:block>
>>>> </fo:table-cell>
>>>> </xsl:for-each>
>>>> </fo:table-row>
>>>> </xsl:for-each>
>>>> </fo:table-body>
>>>> </fo:table>
>>>> </fo:block>
>>>> </xsl:template>
>>>>
>>>>
>>>> I am attaching a file with this which contain the required ouptut.
>>>>
>>>> http://old.nabble.com/file/p27430837/Table.doc Table.doc
>>>>
>>>>
>>>>
>>>> But i am not getting that output instead it throws a exception. Please
>>>> let me know if i am missing something.
>>>>
>>>> The stack trace is as follows
>>>>
>>>> java.lang.ArrayIndexOutOfBoundsException: -2
>>>>
>>>> Cocoon stacktrace:
>>>>
>>>> java.lang.ArrayIndexOutOfBoundsException: -2
>>>> context://prd-doc/doc2road.xsl - 7:18
>>>>
>>>> Failed to process pipeline
>>>> context://prd-doc/doc2road.xsl - 7:18 [TransformerException]
>>>> context://prd-doc/sitemap.xmap - 63:46 <map:serialize type="fo2pdf">
>>>> context://prd-doc/sitemap.xmap - 62:51 <map:transform>
>>>> context://prd-doc/sitemap.xmap - 61:45 <map:generate>
>>>> context://sitemap.xmap - 1034:92 <map:mount>
>>>>
>>>> Any help would be greatly appreciated.
>>>>
>>>>
>>>>
>>>> Thanks in Advance
>>>>
>>>> Anandh
>>>>
>>>
>>>
>>
>>
>
>
--
View this message in context: http://old.nabble.com/Table-Manipulation-tp27430837p27448047.html
Sent from the w3.org - www-xsl-fo mailing list archive at Nabble.com.
Received on Thursday, 4 February 2010 05:51:55 UTC