Solved

Cannot render info. with tables using XSL-FO

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

Title # Comments Views Activity
Unattended XML settings 4 103
How do the JavaScript &&  !== operators work together? 3 50
Coldfusion- Create and save form elements in Database 7 61
XSLT XML 4 14
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now