Solved

Cannot render info. with tables using XSL-FO

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

810 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