[jdom-interest] Re: JDOMException: Invalid Unicode character (0x0)

Joseph Bowbeer jozart at csi.com
Sat Mar 10 14:33:30 PST 2001


The only legal characters in "parsed entities" are:

#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]

Spec: http://www.xml.com/axml/target.html#NT-Char

In other words, there are only 3 legal characters between 0x0 and 0x31, and
0x0 isn't one of them.

Parsed entities, by the way, applies to everything in your example.  There
are such things as unparsed entities, but these can only appear in the
value of attributes declared as type ENTITY or ENTITIES:

I think you're on the right track to suspect there's some extra stuff past
the end of the document.  Maybe you need to get a valid content length from
IFS and then clip the input to the actual length.

----- original message -----

From: James Scott jscott at hnt.com
Date: Sat, 10 Mar 2001 16:57:08 -0500

I'm retrieving an XML-format string from Oracle's Internet File System (IFS)
and passing it to a SAXBuilder to create a Document type. When I do this,
the SAXBuilder throws the folowing exception:

org.jdom.JDOMException: Error on line 14: An invalid XML character (Unicode:
0x0) was found in the element content of the document.

The document in question is:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
<xsl:template match="/">
  <title>Portal example</title>
<H1>For you, we have some portlets.</H1>
<xsl:apply-templates match="portlets"/>

As the file is only 14 lines long, I assume that it's some kind of problem
with the end-of-file or end-of-string marker. A little net.research led me
to believe that it might be a UTF-8 vs. UTF-16 problem, but I can't get
around it by constructing a new String(oldString.getBytes, "UTF8").

Thanks in advance for any help you might be able to provide. Until this,
I've had a great experience with JDOM, and I'm sure I'm missing something

More information about the jdom-interest mailing list