Solved

Cannot render info. with tables using XSL-FO

Posted on 2004-09-01
4
394 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

623 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