[jdom-interest] FODC0002: java.io.UTFDataFormatException: Invalid
byte 1 of 1-byte UTF-8
Jack Bush
netbeansfan at yahoo.com.au
Mon Aug 16 06:30:29 PDT 2010
Hi All,
I am getting the following error when reading secondary xml documents using
document() in XSLT 2.0 stylesheet from within an EJB (Glassfish 2.1) container:
Recoverable error on line 8
FODC0002: java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8
sequence.
The transformation snippet in Java is as follows:
TransformerFactory transformerFactory = new
net.sf.saxon.TransformerFactoryImpl();
transformerFactory.setAttribute("http://saxon.sf.net/feature/sourceParserClass","org.apache.xml.resolver.tools.ResolvingXMLReader");
FileInputStream stylesheet = new FileInputStream("C:/stylesheet.xsl");
Transformer transformer = transformerFactory.newTransformer(new
StreamSource(stylesheet));
JDOMSource source = new JDOMSource(mainJDomDocument);
JDOMResult result = new JDOMResult();
transformer.transform(source, result);
The relevant lines in C:/stylesheet.xsl is:
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <xsl:stylesheet version="2.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:xs="http://www.w3.org/2001/XMLSchema"
5 exclude-result-prefixes="ns">
6
7 <xsl:template match="/">
8 <xsl:apply-templates select="document('file:///C:/car.xml'))/catalog">
...........
15 </xsl:apply-templates>
16 </xsl:template>
17
18 .........
All xml documents have been encoded with UTF-8. Changing encoding on
C:/stylesheet.xsl to UTF-8 or using InputStreamReader(styleSheetIS,"UTF-8") did
not make any difference. This application have been working fine until it
is moved into an EJB 3.0 (Glassfish 2.1) container. It appears that it is the
EJB container which has overrided the way these secondary documents have been
read using a different method that checks the encoding. I believe from other
threats that the same issue also occur in a web container as well.
I am running JDK 1.6.0_17, Netbeans 6.7, XSLT 2.0 (Saxon 9.1), JDOM 1.1 on
Windows XP.
Any suggestion would be appreciated.
Thanks a lot,
Jack
More information about the jdom-interest
mailing list