Bug 43307 - Misleading Error Message w/ XML+XSL input
Summary: Misleading Error Message w/ XML+XSL input
Status: CLOSED INVALID
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: pdf (show other bugs)
Version: 0.94
Hardware: Other other
: P4 minor
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords: ErrorMessage
Depends on:
Blocks:
 
Reported: 2007-09-04 09:17 UTC by Drew
Modified: 2012-04-01 13:48 UTC (History)
0 users



Attachments
TEMP.XSL (1.05 KB, text/plain)
2007-09-04 09:18 UTC, Drew
Details
TEMP.XML (128 bytes, text/plain)
2007-09-04 09:19 UTC, Drew
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Drew 2007-09-04 09:17:28 UTC
Despite how the previous bug report was closed, this is still unresolved in the 
public release of 0.94.  If the user mistaken types in "text-weight" instead 
of "font-weight", FOP reports a generic error (included below) that does not 
elude to the words text-weight or a line number in which to find the problem.

I redownloaded FOP, again, just to be sure FOP was the latest release version.  
I picked up:
fop-0.94-bin-jdk1.4.zip              23-Aug-2007 16:55   19M  


using command: fop -xsl temp.xsl -xml temp.xml -pdf output.pdf

My entire XSL file: (with the previous erroneous data text-weight="bold")

<?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" 
xmlns:java="http://xml.apache.org/xslt/java" >
<xsl:template match="/">
<fo:root>
        <fo:layout-master-set>
        <fo:simple-page-master margin-right=".5in" margin-left=".5in" margin-
bottom=".25in" margin-top=".5in" page-width="8.5in" page-height="11in" master-
name="Simple">
         <fo:region-body margin-top="0cm"/>			
         <fo:region-before extent="1.5cm"/>
         <fo:region-after extent="1cm"/>
       </fo:simple-page-master>
     </fo:layout-master-set>
     <fo:page-sequence master-reference="Simple" initial-page-number="1" force-
page-count="no-force">
     <fo:flow flow-name="xsl-region-body">
     <!-- ===========FO CODE STARTS =============== -->
     <fo:block/>
     <fo:block text-weight="bold">
     $ 
     </fo:block>

     <!-- ===========FO CODE ENDS ================= -->
     </fo:flow>
  </fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>

XML File:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="temp.xsl"?>
<vars>
   <appid>123456</appid>
</vars>


What fop reported as the error.  Read carefully, there is no mention of text-
weight:
--- Standard Error ---
Sep 4, 2007 12:15:24 PM org.apache.fop.fo.FOTreeBuilder$MainFOHandler endElement
WARNING: Mismatch: flow (http://www.w3.org/1999/XSL/Format) vs. block 
(http://www.w3.org/1999/XSL/Format)
Sep 4, 2007 12:15:24 PM org.apache.fop.fo.FOTreeBuilder$MainFOHandler endElement
WARNING: Mismatch: page-sequence (http://www.w3.org/1999/XSL/Format) vs. flow 
(http://www.w3.org/1999/XSL/Format)
Sep 4, 2007 12:15:24 PM org.apache.fop.fo.FOTreeBuilder$MainFOHandler endElement
WARNING: Mismatch: root (http://www.w3.org/1999/XSL/Format) vs. page-sequence 
(http://www.w3.org/1999/XSL/Format)
Sep 4, 2007 12:15:24 PM org.apache.fop.fo.FOTreeBuilder fatalError
SEVERE: javax.xml.transform.TransformerException: 
java.lang.IllegalStateException: endElement() called for fo:root where there is 
no current element.
Sep 4, 2007 12:15:24 PM org.apache.fop.cli.Main startFOP
SEVERE: Exception
javax.xml.transform.TransformerException: java.lang.IllegalStateException: 
endElement() called for fo:root where there is no current element.
	at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:168)
	at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:115)
	at org.apache.fop.cli.Main.startFOP(Main.java:160)
	at org.apache.fop.cli.Main.main(Main.java:191)

---------

; SystemID: file:/C:/DocPrep/temp.xsl; Line#: 4; Column#: 10
javax.xml.transform.TransformerException: java.lang.IllegalStateException: 
endElement() called for fo:root where there is no current element.
	at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates
(TransformerImpl.java:2416)
	at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode
(TransformerImpl.java:2281)
	at org.apache.xalan.transformer.TransformerImpl.transformNode
(TransformerImpl.java:1367)
	at org.apache.xalan.transformer.TransformerImpl.transform
(TransformerImpl.java:709)
	at org.apache.xalan.transformer.TransformerImpl.transform
(TransformerImpl.java:1284)
	at org.apache.xalan.transformer.TransformerImpl.transform
(TransformerImpl.java:1262)
	at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:165)
	at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:115)
	at org.apache.fop.cli.Main.startFOP(Main.java:160)
	at org.apache.fop.cli.Main.main(Main.java:191)
Caused by: java.lang.IllegalStateException: endElement() called for fo:root 
where there is no current element.
	at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement
(FOTreeBuilder.java:368)
	at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:194)
	at org.apache.xml.serializer.ToXMLSAXHandler.endElement
(ToXMLSAXHandler.java:261)
	at org.apache.xalan.templates.ElemLiteralResult.execute
(ElemLiteralResult.java:1399)
	at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates
(TransformerImpl.java:2411)
	... 9 more
---------
java.lang.IllegalStateException: endElement() called for fo:root where there is 
no current element.
	at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement
(FOTreeBuilder.java:368)
	at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:194)
	at org.apache.xml.serializer.ToXMLSAXHandler.endElement
(ToXMLSAXHandler.java:261)
	at org.apache.xalan.templates.ElemLiteralResult.execute
(ElemLiteralResult.java:1399)
	at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates
(TransformerImpl.java:2411)
	at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode
(TransformerImpl.java:2281)
	at org.apache.xalan.transformer.TransformerImpl.transformNode
(TransformerImpl.java:1367)
	at org.apache.xalan.transformer.TransformerImpl.transform
(TransformerImpl.java:709)
	at org.apache.xalan.transformer.TransformerImpl.transform
(TransformerImpl.java:1284)
	at org.apache.xalan.transformer.TransformerImpl.transform
(TransformerImpl.java:1262)
	at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:165)
	at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:115)
	at org.apache.fop.cli.Main.startFOP(Main.java:160)
	at org.apache.fop.cli.Main.main(Main.java:191)

--- Standard Output ---
"java"

If there is a newer version of FOP that you are using that has fixed this 
issue, please let me know.
Comment 1 Drew 2007-09-04 09:18:51 UTC
Created attachment 20767 [details]
TEMP.XSL

Attached file with error of "text-weight" that caused the unhandled error in
FOP.
Comment 2 Drew 2007-09-04 09:19:51 UTC
Created attachment 20768 [details]
TEMP.XML

attached XML file, used for building the fo from XSL
Comment 3 Andreas L. Delmelle 2007-09-04 10:00:02 UTC
Confirmed. The misleading error message only appears when using XML+XSL as input. If you first perform 
the XSL transform, and run the resulting FO through FOP from the command-line, then the behavior is 
correct: ValidationException() on the 'text-weight' property.
Comment 4 Andreas L. Delmelle 2007-09-04 10:28:51 UTC
Did a very quick debug session, and something very weird is going on when using XML+XSL as input. 
I placed some breakpoints in PropertyList, and noticed that convertAttributeToProperty() is called 4(!) 
times for the erroneous text-weight property.

Everything works nicely, up until the call to FObj.attributeError(). Instead of causing a ValidationException, 
it seems the exception is swallowed by Xalan, which apparently recovers from it and happily tries to 
continue the transform... Have you tried a different XSLT processor?
Comment 5 Andreas L. Delmelle 2007-09-04 10:46:58 UTC
Yup. Looking a bit closer, could be the bug should be filed against Xalan here (2.7.0).

Not a 100% sure, but instead of re-throwing the Exception, the XSLT processor seems to be triggered into 
a flush (?)
Comment 6 Drew 2007-09-04 11:07:44 UTC
I'm getting the same error in 0.93, I pulled 0.93 from "previous fop binary
package" and it registers as 0.93 under its -v (version) option.  

FOP 0.20.5 ignores the error parameter entirely:

[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
[ERROR] property 'text-weight' ignored
[INFO] [1]
[INFO] Parsing of document complete, stopping renderer
Comment 7 Andreas L. Delmelle 2007-09-04 11:20:48 UTC
(In reply to comment #6)
> I'm getting the same error in 0.93, I pulled 0.93 from "previous fop binary
> package" and it registers as 0.93 under its -v (version) option.  

OK. What I actually meant by 'different processor', was plugging in Saxon instead of Xalan (which is 
distributed with FOP and bundled with some JVMs).

> 
> FOP 0.20.5 ignores the error parameter entirely:

This behavior can be mimicked in 0.9x by turning off strict-validation in the configuration (see: http://
xmlgraphics.apache.org/fop/0.94/configuration.html)

It is not recommended to do so, but seems a viable option to work around this and avoid the exception 
altogether.
Comment 8 Andreas L. Delmelle 2007-09-05 13:10:39 UTC
Did some further testing, and I am now definitely going to close this one.

When using other versions of Xalan, the problem does not occur. We cannot do anything about this at the 
FOP side.
Try replacing your XSLT processor to avoid the problem, or check with xalan-dev if it is a known bug and 
whether a patch is available.
Comment 9 Glenn Adams 2012-04-01 13:48:44 UTC
batch transition to closed remaining pre-FOP1.0 resolved bugs