Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8933171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:28:36+00:00 2026-06-15T09:28:36+00:00

I am trying to generate a pdf using apache-fop from the following command. C:\fop-1.0-bin\fop-1.0>fop

  • 0

I am trying to generate a pdf using apache-fop from the following command.

C:\fop-1.0-bin\fop-1.0>fop -xml sample1.xml -xsl xsl-fo.xsl -pdf sample2.pdf

My xml looks like this

<?xml version="1.0" encoding="iso-8859-1"?>
<service>
    <serviceId>11111</serviceId>
    <openDate>2012-02-16</openDate>
    <closeDate>2012-02-16</closeDate>
    <description>INSPECT MACHINE</description>
    <repairCost>$266.76</repairCost>
</service>

My xsl-fo xslt file looks like this

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    >
    <xsl:output encoding="iso-8859-1" />
    <xsl:template match ="Service">
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
            <fo:layout-master-set>
                <fo:simple-page-master master-name="Service">
                    <fo:region-body></fo:region-body>
                </fo:simple-page-master>
            </fo:layout-master-set>

            <fo:page-sequence master-reference="Service">
                <fo:flow flow-name="xsl-region-body">
                    <fo:block>
                        <fo:table>
                            <fo:table-body>
                                <fo:table-row>
                                    <fo:table-cell border="solid 1px black" 
                                    text-align="center" font-weight="bold">
                                        <fo:block>Service Id</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border="solid 1px black" 
                                    text-align="center" font-weight="bold">
                                        <fo:block>Open Date</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border="solid 1px black" 
                                    text-align="center" font-weight="bold">
                                        <fo:block>Close Date</fo:block>
                                    </fo:table-cell>                                    
                                    <fo:table-cell border="solid 1px black" 
                                    text-align="center" font-weight="bold">
                                        <fo:block>Order Status</fo:block>
                                    </fo:table-cell>                                    
                                    <fo:table-cell border="solid 1px black" 
                                    text-align="center" font-weight="bold">
                                        <fo:block>Description</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border="solid 1px black" 
                                    text-align="center" font-weight="bold">
                                        <fo:block>Repair Cost</fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                                <xsl:for-each select="./servicetype">
                                    <fo:table-row>
                                        <fo:table-cell border="solid 1px bold" text-align="center">
                                            <fo:block><xsl:value-of select="serviceId" /></fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border="solid 1px bold" text-align="center">
                                            <fo:block><xsl:value-of select="openDate" /></fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border="solid 1px bold" text-align="center">
                                            <fo:block><xsl:value-of select="closeDate" /></fo:block>
                                        </fo:table-cell>                                

                                        <fo:table-cell border="solid 1px bold" text-align="center">
                                            <fo:block><xsl:value-of select="description" /></fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border="solid 1px bold" text-align="center">
                                            <fo:block><xsl:value-of select="repairCost" /></fo:block>
                                        </fo:table-cell>
                                    </fo:table-row>
                                </xsl:for-each>
                            </fo:table-body>
                        </fo:table>
                    </fo:block>
                </fo:flow>
            </fo:page-sequence>
        </fo:root>
    </xsl:template>
</xsl:stylesheet>

I am getting error. Can someone point out my error in the code. I am following this example http://www.codeproject.com/Articles/37663/PDF-Generation-using-XSLFO-and-FOP

SEVERE: org.apache.fop.fo.ValidationException: Document is empty (something migh
t be wrong with your XSLT stylesheet).
Dec 3, 2012 4:27:27 PM org.apache.fop.cli.Main startFOP
SEVERE: Exception
javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException:
 Document is empty (something might be wrong with your XSLT stylesheet).
        at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:302)
        at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:130)
        at org.apache.fop.cli.Main.startFOP(Main.java:174)
        at org.apache.fop.cli.Main.main(Main.java:205)
Caused by: javax.xml.transform.TransformerException: org.apache.fop.fo.Validatio
nException: Document is empty (something might be wrong with your XSLT styleshee
t).
        at org.apache.xalan.transformer.TransformerImpl.transformNode(Transforme
rImpl.java:1430)
        at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
l.java:709)
        at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
l.java:1284)
        at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
l.java:1262)
        at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:299)
        ... 3 more
Caused by: org.apache.fop.fo.ValidationException: Document is empty (something m
ight be wrong with your XSLT stylesheet).
        at org.apache.fop.events.ValidationExceptionFactory.createException(Vali
dationExceptionFactory.java:38)
        at org.apache.fop.events.EventExceptionManager.throwException(EventExcep
tionManager.java:54)
        at org.apache.fop.events.DefaultEventBroadcaster$1.invoke(DefaultEventBr
oadcaster.java:175)
        at $Proxy0.emptyDocument(Unknown Source)
        at org.apache.fop.fo.FOTreeBuilder.endDocument(FOTreeBuilder.java:158)
        at org.apache.xml.serializer.ToXMLSAXHandler.endDocument(ToXMLSAXHandler
.java:181)
        at org.apache.xalan.transformer.TransformerImpl.transformNode(Transforme
rImpl.java:1378)
        ... 7 more
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:28:37+00:00Added an answer on June 15, 2026 at 9:28 am

    try changing the xpath in the foreach

    <xsl:for-each select="./service">
    

    xml:

    <?xml version="1.0" encoding="iso-8859-1"?>
    <services>
        <service>
            <serviceId>11111</serviceId>
            <openDate>2012-02-16</openDate>
            <closeDate>2012-02-16</closeDate>
            <orderStatus>Status2</orderStatus>
            <description>INSPECT MACHINE</description>
            <repairCost>$266.76</repairCost>
        </service>
        <service>
            <serviceId>11111</serviceId>
            <openDate>2012-02-16</openDate>
            <closeDate>2012-02-16</closeDate>
            <orderStatus>Status1</orderStatus>
            <description>INSPECT MACHINE</description>
            <repairCost>$266.76</repairCost>
        </service>
    </services>
    

    xsl:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.1"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:output encoding="iso-8859-1" />
    <xsl:template match ="services">
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
            <fo:layout-master-set>
                <fo:simple-page-master master-name="service">
                    <fo:region-body></fo:region-body>
                </fo:simple-page-master>
            </fo:layout-master-set>
    
            <fo:page-sequence master-reference="service">
                <fo:flow flow-name="xsl-region-body">
                    <fo:block>
                        <fo:table>
                            <fo:table-body>
                                <fo:table-row>
                                    <fo:table-cell border="solid 1px black" 
                                    text-align="center" font-weight="bold">
                                        <fo:block>Service Id</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border="solid 1px black" 
                                    text-align="center" font-weight="bold">
                                        <fo:block>Open Date</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border="solid 1px black" 
                                    text-align="center" font-weight="bold">
                                        <fo:block>Close Date</fo:block>
                                    </fo:table-cell>                                    
                                    <fo:table-cell border="solid 1px black" 
                                    text-align="center" font-weight="bold">
                                        <fo:block>Order Status</fo:block>
                                    </fo:table-cell>                                    
                                    <fo:table-cell border="solid 1px black" 
                                    text-align="center" font-weight="bold">
                                        <fo:block>Description</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border="solid 1px black" 
                                    text-align="center" font-weight="bold">
                                        <fo:block>Repair Cost</fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                                <xsl:for-each select="./service">
                                    <fo:table-row>
                                        <fo:table-cell border="solid 1px bold" text-align="center">
                                            <fo:block><xsl:value-of select="serviceId" /></fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border="solid 1px bold" text-align="center">
                                            <fo:block><xsl:value-of select="openDate" /></fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border="solid 1px bold" text-align="center">
                                            <fo:block><xsl:value-of select="closeDate" /></fo:block>
                                        </fo:table-cell>                                
                                        <fo:table-cell border="solid 1px bold" text-align="center">
                                            <fo:block><xsl:value-of select="orderStatus" /></fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border="solid 1px bold" text-align="center">
                                            <fo:block><xsl:value-of select="description" /></fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border="solid 1px bold" text-align="center">
                                            <fo:block><xsl:value-of select="repairCost" /></fo:block>
                                        </fo:table-cell>
                                    </fo:table-row>
                                </xsl:for-each>
                            </fo:table-body>
                        </fo:table>
                    </fo:block>
                </fo:flow>
            </fo:page-sequence>
        </fo:root>
    </xsl:template>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to generate a PDF using XSL(XML-FO) to transform a generated XML
I'm trying to create a PDF document with Apache FOP from an xml file
I'm trying to generate a pdf from template using this snippet: def write_pdf(template_src, context_dict):
I'm trying to generate a PDF file using AJAX call in Rails3. The following
I'm trying to generate a pdf file from data in a database using JasperReports
I'm trying to generate a PDF document using FOP and Java. I receive the
I'm trying to generate a PDF document using FOP. The pdf generation code is
I am trying to generate pdf using Dompdf. I have the following script for
I am trying to generate PDF document from HTML using wkhtmltopdf . But I
I'm trying to generate PDF/A-1b document from a website using EvoPDF v3.0 When I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.