Solved

Cannot render info. with tables using XSL-FO

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
API Soap Calls 4 126
XML XSLT If loop 4 30
Download a website to hdd 2 82
write xml in vb.net 2 34
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

820 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