Greg,

Can you show how you are calling into FOP?  Through the command-line or 
embedded in your Java app?  FOP can take either an XSL-FO document or an 
XML/XSLT document pair that generates the XSL-FO and then turns around and 
processes that FO.  While I'm guessing a bit here, this error seems like 
something that would happen if you were using the XSL-FO input example but 
passing in an XSLT stylesheet instead of an XSL-FO doc.

 

For example, to pass XML/XSLT into FOP do something like this (taken from the 
FOP examples):

 

                TransformerFactory factory = TransformerFactory.newInstance();

                Transformer transformer = factory.newTransformer(new 
StreamSource(xsltfile));

                Source src = new StreamSource(xmlfile);

                Result res = new SAXResult(fop.getDefaultHandler());

                transformer.transform(src, res);

 

But to just pass in an FO doc:

 

            TransformerFactory factory = TransformerFactory.newInstance();

            Transformer transformer = factory.newTransformer();

            Source src = new StreamSource(fo);

            Result res = new SAXResult(fop.getDefaultHandler());

            transformer.transform(src, res);

 

Something else to try is to just take FOP out of the equation and do a simple 
XSLT transformation.  You would expect an XSL-FO document as the result of the 
transformation, and if that doesn't happen then that would point you to why FOP 
is choking.

 

Sean

 

From: Patterson, Gregory Michael [mailto:[email protected]] 
Sent: Tuesday, December 16, 2008 3:16 PM
To: [email protected]
Subject: FOP XML->XSLT->FOP PDF Issues

 

Hello,

I'm having some trouble getting the FOP to properly use an xslt stylesheet.

I am getting a ValidationException saying I need to put fo:root at the top.

My first element is an xsl element, but the first fo: element is

fo:root.  This is exactly the same format as the examples in the fop

examples packages.

 

In my case, I need to pull the appropriate xsl from a database, and 

below is what I'm getting back:

<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet 
xmlns:fo="http://www.w3.org/1999/XSL/Format"; 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; exclude-result-prefixes="fo" 
version="1.1">

  <xsl:output indent="yes" method="xml" omit-xml-declaration="no" 
version="1.0"/>

  <xsl:param name="versionParam" select="'1.0'"/> 

  <!-- ========================= -->

  <!-- root element: projectteam -->

  <!-- ========================= -->

  <xsl:template match="projectteam">

    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format";>

      <fo:layout-master-set>

.

.

.

 

 

 

Here is the error: 

(Location of error unknown)org.apache.fop.fo.ValidationException: Error: First 
element must be the fo:root formatting object. Found (Namespace URI: "", Local 
Name: "stylesheet") instead. Please make sure you're producing a valid XSL-FO 
document

Finished.

 

If you'll notice, the first fo element is fo:root, but I do have other things 
(required afaik) before it.

Thanks in advance for any help.

-Greg

----------------------------------------------------------------------
CONFIDENTIALITY NOTICE This message and any included attachments are from 
Cerner Corporation and are intended only for the addressee. The information 
contained in this message is confidential and may constitute inside or 
non-public information under international, federal, or state securities laws. 
Unauthorized forwarding, printing, copying, distribution, or use of such 
information is strictly prohibited and may be unlawful. If you are not the 
addressee, please promptly delete this message and notify the sender of the 
delivery error by e-mail or you may call Cerner's corporate offices in Kansas 
City, Missouri, U.S.A at (+1) (816)221-1024.

Reply via email to