You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Ronald Bourret <rp...@hotmail.com> on 2000/06/13 13:39:20 UTC
BUG: StringIndexOutOfBoundsException
Namespaces and entity references don't seem to like each other. In
particular, the following code returns a StringIndexOutOfBoundsException. If
I remove the call to set the namespaces feature to true, or if I remove the
entity reference from the XML document, the exception is not thrown.
-- Ron Bourret
============================
Code:
import java.io.File;
import org.apache.xerces.parsers.DOMParser;
import org.xml.sax.InputSource;
import org.w3c.dom.Document;
public class TestXerces2
{
public static void main (String[] argv) throws Exception
{
String xmlFilename = argv[0];
DOMParser parser = new DOMParser();
parser.setFeature("http://xml.org/sax/features/namespaces", true);
// Parse the input file
parser.parse(new InputSource(getFileURL(xmlFilename)));
}
static String getFileURL(String fileName)
{
File file;
String path, separator;
file = new File(fileName);
return "file:///" + file.getAbsolutePath();
}
}
=========================================
XML Document:
<?xml version="1.0" ?>
<!DOCTYPE A [
<!ENTITY foo '<B/>'>
]>
<A>&foo;</A>
==========================================
Output:
C:>java TestXerces2 tx2.xml
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String
index out of range: -1
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:834)
at TestXerces2.main(TestXerces2.java:18)
C:>
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
Re: BUG: StringIndexOutOfBoundsException
Posted by Andy Clark <an...@apache.org>.
Ronald Bourret wrote:
> Namespaces and entity references don't seem to like each other. In
> particular, the following code returns a StringIndexOutOfBoundsException. If
> I remove the call to set the namespaces feature to true, or if I remove the
> entity reference from the XML document, the exception is not thrown.
Thanks for the excellent bug report. It is now fixed and is
available in CVS.
--
Andy Clark * IBM, JTC - Silicon Valley * andyc@apache.org