You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by "Rathi, Pradeep" <pr...@documentum.com> on 2001/02/16 18:59:35 UTC

RE: xerces 1.1.1 -> 1.3.0 probs

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
> 

RE: xerces 1.1.1 -> 1.3.0 probs

Posted by aazz <aa...@leopard.com>.
Thanks Pradeep,
That appears to fix it. Anyone know when this bug will be fixed?
Also will this fixer code backwards compatible with the xerces versions that
don't have this bug? 

thanks

On Fri, 16 Feb 2001, Rathi, Pradeep wrote:
> >%_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
> > 
> 

----------------------------------------
Content-Type: text/html; name="unnamed"
Content-Transfer-Encoding: quoted-printable
Content-Description: 
----------------------------------------