[jdom-interest] FODC0002: java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8

Michael Kay mike at saxonica.com
Mon Aug 16 07:32:06 PDT 2010


This is nothing to do with JDOM - you are on the wrong list. The problem 
is with a document that is being read using the document() function 
within your Saxon stylesheet. The error means that the XML parser is 
trying to read the document ("car.xml") as UTF-8, but it contains byte 
combinations that are not valid in UTF-8.

You need to change the XML declaration of car.xml so that it correctly 
describes the actual encoding of the file.

Michael Kay
Saxonica

On 16/08/2010 14:30, Jack Bush wrote:
> 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
>
>
>
>
>
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
>
>    



More information about the jdom-interest mailing list