xsl-list
[Top] [All Lists]

how i can use 'table' in fo in differt way ?

2004-04-16 02:46:10

Hello all,
i write a tool to convert a xml document in PDF using
fo.

The problem is that when a use a 'table' in the xsl
file , it forces me to indicate how many columns i
need to use and the width.

In my script i have two columns.
I want that :
when the text of the second column is empty , 
the text of the first column takes all the line of the
document like that :

                     Name
                  Title name

ChapterName
Paragraph                               TextLine
Paragraph                               TextLine
Paragraph                               TextLine

ChapterName text text text text text text text text 

ChapterName
Paragraph                               TextLine
Paragraph                               TextLine
Paragraph                               TextLine
                   
                
#...............................................
But i have this output:

                    Name
                 Title name
ChapterName
Paragraph                               TextLine
Paragraph                               TextLine
Paragraph                               TextLine

ChapterName text text text
text text text text text 

ChapterName
Paragraph                               TextLine
Paragraph                               TextLine
Paragraph                               TextLine

 
Can somebody help me , please?
Thanks in advance ,
Ro

Here is the xsl document and the xml file :


                 <?xml version="1.0"
encoding="ISO-8859-1"?>
                 <xsl:stylesheet version="1.1"
                
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
                      
xmlns:fo="http://www.w3.org/1999/XSL/Format";
                 exclude-result-prefixes="fo">
                   <xsl:output method="xml"
version="1.0"
                 omit-xml-declaration="no"
indent="yes"/>
                   <!-- ========================= -->
                   <!-- root element: General2FO  -->
                   <!-- ========================= -->
                   <xsl:template match="ROOT">
                     <fo:root
                
xmlns:fo="http://www.w3.org/1999/XSL/Format";>
                       
                       <fo:layout-master-set>
                         <fo:simple-page-master
master-name="simpleA4"
                 page-height="29.7cm"
page-width="21cm"
                                    margin-top="2cm"
                 margin-bottom="2cm" margin-left="2cm"
                 margin-right="2cm">
                           <!-- Page template goes
here -->
                           <fo:region-body/>
                         </fo:simple-page-master>
                       </fo:layout-master-set>
                       <fo:page-sequence
master-reference="simpleA4">
                         <!-- Page content goes here
--> 
                         <fo:flow
flow-name="xsl-region-body">
                           <xsl:apply-templates
select="Name |
                 TitleName | Chapter"/>
                         </fo:flow>
                       </fo:page-sequence>
                     
                     </fo:root>
                   </xsl:template>

                   <xsl:template match="Name">
                     <fo:block font-size="8pt"
text-align-last="center"
                 font-weight="bold"
font-family="sans-serif">
                       <xsl:value-of select="."/>
                     </fo:block>
                     <fo:block space-before="4pt"
space-after="4pt"/> 
                   </xsl:template>

                   <xsl:template match="TitleName">
                     <fo:block font-size="18pt"
                 text-align-last="center"
font-weight="bold"
                 font-family="sans-serif">
                       <xsl:value-of select="."/>
                     </fo:block>
                     <fo:block space-before="4pt"
space-after="4pt"/> 
                   </xsl:template>

                 <xsl:template match="Chapter">
                     <fo:table table-layout="fixed">
                       <fo:table-column
column-width="5cm"/>
                       <fo:table-column
column-width="12cm"/>
                       <fo:table-body>
                         <xsl:apply-templates
select="ChapterHead"/>
                         <xsl:apply-templates
select="ChapterLine"/>
                         <fo:table-row>
                           <fo:table-cell>
                             <fo:block
space-before="4pt"
                 space-after="4pt"/> 
                           </fo:table-cell>
                         </fo:table-row>
                       </fo:table-body>
                     </fo:table>
                   </xsl:template>

                   <xsl:template match="ChapterHead">
                     <fo:table-row>
                       <xsl:apply-templates
select="ChapterName"/>
                       <xsl:apply-templates
select="ChapterNameText"/>
                     </fo:table-row>
                   </xsl:template>

                   <xsl:template match="ChapterLine">
                     <fo:table-row>
                       <xsl:apply-templates
select="Paragraph"/>
                       <xsl:apply-templates
select="TextLine"/>
                     </fo:table-row>
                   </xsl:template>

                   <xsl:template match="ChapterName">
                     <fo:table-cell>
                       <fo:block font-size="10pt"
font-weight="bold"
                 font-family="sans-serif">
                         <xsl:value-of select="."/>
                       </fo:block>
                     </fo:table-cell>
                   </xsl:template>

                   <xsl:template
match="ChapterNameText">
                     <fo:table-cell>
                       <fo:block font-size="10pt"
                 font-family="sans-serif">
                         <xsl:value-of select="."/>
                       </fo:block>
                     </fo:table-cell>
                   </xsl:template>

                   <xsl:template match="Paragraph">
                     <fo:table-cell>
                       <fo:block font-size="10pt"
                 font-family="sans-serif">
                         <xsl:value-of select="."/>
                       </fo:block>
                     </fo:table-cell>
                   </xsl:template>

                   <xsl:template match="TextLine">
                     <fo:table-cell>
                       <fo:block font-size="10pt"
                 font-family="sans-serif">
                         <xsl:value-of select="."/>
                       </fo:block>
                     </fo:table-cell>
                   </xsl:template>
                 </xsl:stylesheet>



                 <?xml version="1.0"
encoding="ISO-8859-1"?>
                 <!DOCTYPE ROOT SYSTEM
"GENERALDEFINITION.dtd">
                 <ROOT>
                   <Name>Name</Name>
                   <TitleName>Title name</TitleName>
                     <Chapter>
                     <ChapterHead>
                      
<ChapterName>ChapterName</ChapterName>
                     </ChapterHead>
                     <ChapterLine>
                      
<Paragraph>Paragraph</Paragraph>
                       <TextLine>TextLine</TextLine>
                     </ChapterLine>
                     <ChapterLine>
                      
<Paragraph>Paragraph</Paragraph>
                       <TextLine>TextLine</TextLine>
                     </ChapterLine>
                     <ChapterLine>
                      
<Paragraph>Paragraph</Paragraph>
                       <TextLine>TextLine</TextLine>
                     </ChapterLine>
                   </Chapter>
                   <Chapter>
                     <ChapterHead>
                       <ChapterName>ChapterName text
text text text
                 text text text text text text
text</ChapterName>
                     </ChapterHead>
                   </Chapter>
                   <Chapter>
                     <ChapterHead>
                      
<ChapterName>ChapterName</ChapterName>
                     </ChapterHead>
                     <ChapterLine>
                      
<Paragraph>Paragraph</Paragraph>
                       <TextLine>TextLine</TextLine>
                     </ChapterLine>
                     <ChapterLine>
                      
<Paragraph>Paragraph</Paragraph>
                       <TextLine>TextLine</TextLine>
                     </ChapterLine>
                     <ChapterLine>
                      
<Paragraph>Paragraph</Paragraph>
                       <TextLine>TextLine</TextLine>
                     </ChapterLine>
                   </Chapter>

                 </ROOT>




        
        
                
____________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping" 
your friends today! Download Messenger Now 
http://uk.messenger.yahoo.com/download/index.html