Solved

Cannot render info. with tables using XSL-FO

Posted on 2004-09-01
4
392 Views
Last Modified: 2013-11-18
My XML file.

<Employee>
      <Name>Sun</Name>
      <Name>Moon</Name>
      <Name>Earth</Name>
</Employee>





Here is my xsl file.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:fo="http://www.w3.org/1999/XSL/Format">
 
 <xsl:template match="/">
 
  <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
 
   <fo:layout-master-set>
     <fo:simple-page-master master-name="simple"
                   page-height="29.7cm"
                   page-width="21cm"
                   margin-top="1cm"
                   margin-bottom="2cm"
                   margin-left="2.5cm"
                   margin-right="2.5cm">
       <fo:region-body margin-top="3cm"/>
       <fo:region-before extent="3cm"/>
       <fo:region-after extent="1.5cm"/>
     </fo:simple-page-master>
   </fo:layout-master-set>
 
 
   <fo:page-sequence master-reference="simple">
         <fo:flow flow-name="xsl-region-body">
      <fo:table-and-caption>
      <fo:table>
      <fo:table-body>
           <xsl:for-each select="Employee/Name">
            <fo:table-row>
              <fo:table-cell>
                  <fo:block> <xsl:value-of select="."/> </fo:block>
              </fo:table-cell>
            </fo:table-row>
         </xsl:for-each>
      </fo:table-body>
      </fo:table>
      </fo:table-and-caption>
           </fo:flow>
   </fo:page-sequence>

  </fo:root>
 
 </xsl:template>
 
</xsl:stylesheet>



I Run this command from command prompt.


C:\XSL-FOP\fop-0.20.5>fop -xml c:\xmltopdf\r.xml -xsl c:\xmltopdf\r.xsl -pdf c:\
xmltopdf\r.pdf
[INFO] Using org.apache.xerces.parsers.SAXParser as SAX2 Parser
[INFO] FOP 0.20.5
[INFO] Using org.apache.xerces.parsers.SAXParser as SAX2 Parser
[INFO] building formatting object tree
[INFO] setting up fonts
[INFO] [1]
[INFO] Parsing of document complete, stopping renderer



My problem is nothing shows up in pdf, strangely if i do not use tables, everything works fine....

thanks
Sunil
0
Comment
Question by:sunilramu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Assisted Solution

by:sathishv
sathishv earned 50 total points
ID: 11961126
Just check to see if all the mandatory elements are there inside fo:table (I'm not sure if fo:table-column is mandatory, try it once). Sometimes this happens when you have an empty cell in your table. You can put an empty fo:inline inside the fo:block like this,

<fo:table-cell>
     <fo:block> <xsl:value-of select="."/> <fo:inline></fo:inline></fo:block>
</fo:table-cell>

Hope this helps.

Cheers,
Sathish
0
 

Author Comment

by:sunilramu
ID: 11962146
I tried fixed-style for table and that seems to be working, I shall get bck to you with more details.

0
 
LVL 15

Accepted Solution

by:
dualsoul earned 450 total points
ID: 11970636
who said <fo:table-and-caption> supported by ApacheFOP? i'm not sure

this one will work:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:fo="http://www.w3.org/1999/XSL/Format">
 
 <xsl:template match="/">
 
  <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
 
   <fo:layout-master-set>
     <fo:simple-page-master master-name="simple"
                   page-height="29.7cm"
                   page-width="21cm"
                   margin-top="1cm"
                   margin-bottom="2cm"
                   margin-left="2.5cm"
                   margin-right="2.5cm">
       <fo:region-body margin-top="3cm"/>
       <fo:region-before extent="3cm"/>
       <fo:region-after extent="1.5cm"/>
     </fo:simple-page-master>
   </fo:layout-master-set>
 
 
   <fo:page-sequence master-reference="simple">
        <fo:flow flow-name="xsl-region-body">
       

     <fo:table>                  
               <fo:table-column column-width="150pt" />
     
     <fo:table-body>
          <xsl:for-each select="/Employee/Name">
          <fo:table-row>
            <fo:table-cell>
               <fo:block> <xsl:value-of select="."/> </fo:block>
            </fo:table-cell>
          </fo:table-row>
        </xsl:for-each>
     </fo:table-body>
     </fo:table>
          </fo:flow>
   </fo:page-sequence>

  </fo:root>
 
 </xsl:template>
 
</xsl:stylesheet>
0
 

Author Comment

by:sunilramu
ID: 12038794
fo:table-and-caption is supported, but it only seems to work when you have fixed-style
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question