Hi,
I have got the same problem. When I run FOP as embedded in my
developement server, it is ran without any error. But when I run it on
my production server, I have got the following exception :
org.apache.fop.fo.ValidationException: Error(Unknown location): For
fo:simple-page-master, only one fo:region-body may be declared.
I tried to run the your website example ExampleXML2PDF and I have got
the same issue
org.apache.fop.fo.ValidationException: Error(Unknown location): For
fo:simple-page-master, only one fo:region-body may be declared.
at org.apache.fop.fo.FONode.tooManyNodesError(FONode.java:350)
at
org.apache.fop.fo.pagination.SimplePageMaster.validateChildNode(SimplePageMaster.java:123)
at
org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:303)
at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:185)
at
org.apache.xalan.transformer.ResultTreeHandler.flushElem(ResultTreeHandler.java:860)
at
org.apache.xalan.transformer.ResultTreeHandler.flushPending(ResultTreeHandler.java:954)
at
org.apache.xalan.transformer.ResultTreeHandler.endElement(ResultTreeHandler.java:308)
at
org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:716)
at
org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:425)
at
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:216)
at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2339)
at
org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2160)
at
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1213)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:668)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1129)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1107)
at embedding.ExampleXML2PDF.main(ExampleXML2PDF.java:98)
I use the following libraries
activation.jar
avalon-framework-4.2.0.jar
batik-all-1.6.jar
commons-io-1.2.jar
commons-logging-1.0.4.jar
dom.jar
fesi.jar
fop.jar
jug.jar
lucene-1.2.jar
mail.jar
mysql-connector-java-3.0.7-stable-bin.jar
newsmodule.jar
opencms.jar
rss4j.jar
serializer-2.7.0.jar
Tidy.jar
xalan-2.7.0.jar
xercesImpl-2.6.2.jar
xml-apis-2.6.2.jar
xmlgraphics-commons-1.1.jar
I use xerces-J 2.6.2 because with the 2.7.1, Tomcat 4.3 crashes at startup.
Here is a extract of my XSL :
<?xml version="1.0" encoding="ISO-8859-1" ?>
<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="/decompte">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="decomptes"
page-height="29.7cm"
page-width="21cm"
margin-top="2cm"
margin-bottom="1cm"
margin-left="2.5cm"
margin-right="2.5cm">
<fo:region-body margin-top="1cm" margin-bottom="2cm"/>
<fo:region-before region-name="header" extent="3cm"/>
<fo:region-after region-name="footer" extent="1.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="decomptes">
<fo:static-content flow-name="footer">
<fo:block text-align="right">
Page
<fo:page-number />/<fo:page-number-citation ref-id="theEnd" />
</fo:block>
</fo:static-content>
<fo:static-content flow-name="header">
<fo:block-container height="7cm" width="100%" top="7cm" left="0cm"
position="absolute">
<fo:block background-color="transparent">
<fo:external-graphic
src="../system/galleries/pics/decompte/copie-conforme.svg"
content-height="6.7cm"
vertical-align="middle" />
</fo:block>
</fo:block-container>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
...
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
Where does it come from ?
Best regards,
Xavier
Jeremias Maerki a écrit :
On 11.01.2007 01:22:04 pwillsey wrote:
Jeremias Maerki-2 wrote:
Ok, in this case I'd modify the application so you can write out the
generated FO within your application. Maybe there's something special
about that environment.
I modified the application to do this and then I ran the fo file that was
created through one of the FOP examples provided on your webpage
(ExampleFO2PDF.java) and it successfully converted it from FO to PDF.
So, that means if you run it through FOP in your application, it doesn't
work but if you serialize the XSLT processor's output to an FO file
(instead of calling FOP) in the same environment and format the
resulting file it works. Is that correct? If yes, it's a really weird
problem I cannot help without getting my hands on the whole thing. Sorry.
Jeremias Maerki-2 wrote:
I'm sure you did it right, but are you certain that you properly
override the default XSLT implementation with Xalan 2.7.0 using the
endorsed standards override mechanism?
No I'm not sure I didn't write the code originally I'm very new to using
FOP.
In that case, I suggest you read
http://xmlgraphics.apache.org/fop/faq.html#svg-attribute-required.
Because if you don't know how to properly replace the JAXP
implementations in an environment, you're never sure what version you're
working with.
Here is the code that does the transformation it looks like some of it
came from your examples page:
That code snippet doesn't really help because it doesn't show how you
instantiate the TransformerFactory and how your code looks if you just
serialize to an FO file for testing purposes.
protected byte[] transform() {
byte[] result = null;
_errorCondition = false;
try {
// Setup output
ByteArrayOutputStream out = new ByteArrayOutputStream();
BufferedOutputStream bout = new
BufferedOutputStream(out);
try {
// Construct fop with desired output format
Fop fop =
this.fopFactory().newFop(MimeConstants.MIME_PDF, bout);
// Setup XSLT
Transformer transformer =
this.xsltTransformer();
// Set the value of a <param> in the stylesheet
transformer.setParameter("versionParam", "2.0");
transformer.setErrorListener(this);
if (logger.isDebugEnabled()) {
StringBuffer aLog = new StringBuffer();
aLog.append("transformer
properties:\n");
Properties properties =
transformer.getOutputProperties();
for (Iterator iterator =
properties.keySet().iterator();
iterator.hasNext();) {
String key = (String)
iterator.next();
aLog.append("\t property:" + key + "
value:" + properties.get(key));
}
logger.debug(aLog.toString());
}
// Setup input for XSLT transformation
Source src = this.xsltInput();
// Resulting SAX events (the generated FO) must
be piped through
// to FOP
Result res = new
SAXResult(fop.getDefaultHandler());
// Start XSLT transformation and FOP processing
transformer.transform(src, res);
// Result processing
FormattingResults foResults = fop.getResults();
if (logger.isDebugEnabled()) {
logger.debug("foResults " + foResults);
}
bout.flush();
result = out.toByteArray();
} finally {
out.close();
}
} catch (Exception exception) {
if (logger.isEnabledFor(org.apache.log4j.Level.ERROR)) {
logger.error("Exception ", exception);
}
result = new byte[] {};
}
if (_errorCondition)
result = new byte[] {};
return result;
}
The Exception Occurs on this line:
// Start XSLT transformation and FOP processing
transformer.transform(src, res);
Jeremias Maerki-2 wrote:
I don't think the difference in processor technology should make any
difference here. Normally, the choice of JVM and application server is a
more likely cause.
On 10.01.2007 18:48:12 pwillsey wrote:
I ran the transformation from both computers on the command line, the FO
file
was identical and did not contain a fo:simple-page-master element with
more
then one fo:region-body. I'm using Xalan 2.7.0 on both machines for XSLT
processing. Not sure if this is relevant but the machine I'm having
problems with is running OS X with an intel chip and the development
machine
is a powerpc.
Jeremias Maerki-2 wrote:
If you haven't done so already, run only the XSLT transformation
outside
your application (on the command-line) and inspect the generated FO
file.
You may also need to verify that you're using the same XSLT processor
in
both environments.
On 10.01.2007 06:33:05 pwillsey wrote:
Hello,
I'm getting a validation exception:
javax.xml.transform.TransformerException:
org.apache.fop.fo.ValidationException: Error(Unknown location): For
fo:simple-page-master, only one fo:region-body may be declared.
But I've checked the XLST sheet and there is no fo:simple-page-master
element with more then one fo:region-body. I've also tested this on
another
machine and it works fine. I'm using FOP V. 0.93 (on Both machines).
Not sure if this makes a difference but I'm using FOP in a webobjects
project and I get the exception when I deploy the project but not when
I
run
it using eclipse on my development machine.
Any help would be greatly Appreciated
Jeremias Maerki
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Pour préservez l’environnement n’imprimez cet e-mail qu’en cas de nécessité.
Xavier Ottolini
Développeur multimédia
Adelis
37 rue d'Engwiller
67350 La Walck
France
Téléphone : +33 (0) 3 69 20 29 02
Télécopie : +33 (0) 3 88 72 29 19
http://www.adelis.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]