xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rathi, Pradeep" <pradeep.ra...@documentum.com>
Subject RE: xerces 1.1.1 -> 1.3.0 probs
Date Fri, 16 Feb 2001 17:59:35 GMT
Have you tried this.

Pradeep

-----Original Message-----
From: Michael Bayer
To: xerces-j-user@xml.apache.org
Sent: 02/12/2001 2:27 PM
Subject: NullPointerException in org.apache.xerces.utils.StringPool
(example included!) 



This bug applies to versions 1.2.* and 1.3.* of Xerces.  It does not
exist
in 1.0.* .

It seems the XMLDTDScanner is relying upon the SystemId property of
org.xml.sax.InputSource when an XML document contains external unparsed
entities (example XML is below).  If the SystemId is not set, you get a
NullPointerException at
org.apache.xerces.utils.StringPool.addSymbol(StringPool.java:348).  

Constructing an InputSource from a Reader or InputStream will create
this
behavior, i.e. getSystemId() returns null.  The method
setSystemId(String)
can be called to manually set the systemid as a workaround.

This requirement should be either fixed, or properly handled with a
message (and documented).

Example XML:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE test [
<!ENTITY hello SYSTEM "hello.gif" NDATA gif>
]>


<tag>hello world</tag>




Example program:

import org.xml.sax.*;
import org.xml.sax.helpers.*;
import java.io.*;

public class TestXerces {
	public static void main(String [] argv) {
		String uri = argv[0];

		try {
			XMLReader reader =
XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");

			InputSource i = new InputSource(new
FileReader(uri));

			// uncomment this line to make it work
			//i.setSystemId(uri);

			reader.parse(i);

		}
		catch (SAXException se) {
			if (se.getException() !=
null) se.getException().printStackTrace();
			se.printStackTrace();
		}
		catch (Exception e) {
			e.printStackTrace();
		}

	}
}

usage: 

java TestXerces <filename>





---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org

> -----Original Message-----
> From: aazz [mailto:aaz@leopard.com]
> Sent: Friday, February 16, 2001 10:52 AM
> To: general@xml.apache.org
> Subject: xerces 1.1.1 -> 1.3.0 probs
> 
> 
> Hi,
> We have an app that has been running fine on Xerces 1.1.1 and we just 
> replaed our jar with Xerces 1.3.0. Everything compiles fine, but now 
> when we parse any of our XML files like the sample below, the 
> parser throws a
> null pointer exception. It appears to be around our use of 
> ENTITY references.
> Note the file noted in the SYSTEM ref does exist  and the XML 
> in it is fine and
> can be parsed on its own a-ok. Any Ideas? This works in 1.1.1
> 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <!DOCTYPE  TEST_DOC [
>   <!ENTITY test_xml SYSTEM "/tmp/test.xml">
>   <!ENTITY test2_xml SYSTEM "/tmp/test2.xml">           
> ]>
> 
> 
> <TEST_DOC>
>  &test_xml;
>  &test2_xml;
> </TEST_DOC>
> 
> ---------------------------------------------------------------------
> In case of troubles, e-mail:     webmaster@xml.apache.org
> To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org
> 

Mime
View raw message