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 "Michael Glavassevich (JIRA)" <xe...@xml.apache.org> on 2010/09/08 21:04:32 UTC
[jira] Resolved: (XERCESJ-1465) Entity references not correctly
resolved when DTD is cached
[ https://issues.apache.org/jira/browse/XERCESJ-1465?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Glavassevich resolved XERCESJ-1465.
-------------------------------------------
Resolution: Duplicate
Duplicate of XERCESJ-1205.
> Entity references not correctly resolved when DTD is cached
> -----------------------------------------------------------
>
> Key: XERCESJ-1465
> URL: https://issues.apache.org/jira/browse/XERCESJ-1465
> Project: Xerces2-J
> Issue Type: Bug
> Components: XNI
> Affects Versions: 2.10.0
> Environment: java version "1.6.0_20"
> Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065)
> Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01-279, mixed mode)
> Reporter: Thomas Krammer
>
> When using a XMLGrammarCachingConfiguration to cache the parsed DTD entity references are no longer correctly resolved.
> The following example:
> import org.xml.sax.EntityResolver;
> import org.xml.sax.InputSource;
> import org.xml.sax.SAXException;
> import org.xml.sax.XMLReader;
> import org.xml.sax.helpers.DefaultHandler;
> import javax.xml.parsers.SAXParser;
> import javax.xml.parsers.SAXParserFactory;
> import java.io.IOException;
> import java.io.StringReader;
> public class XercesCachingTest
> {
> public static final String XHTML_1_0_DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" " +
> "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
> public static void main(String[] args) throws Exception
> {
> System.setProperty("org.apache.xerces.xni.parser.XMLParserConfiguration",
> "org.apache.xerces.parsers.XMLGrammarCachingConfiguration");
> final SAXParserFactory factory = SAXParserFactory.newInstance();
> factory.setNamespaceAware(true);
> final SAXParser parser = factory.newSAXParser();
> for(int i=0 ; i< 3 ; i++) {
> parse(parser);
> }
> }
> private static void parse(SAXParser parser)
> throws SAXException, IOException
> {
> final XMLReader reader = parser.getXMLReader();
> reader.setEntityResolver(new EntityResolver()
> {
> @Override
> public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
> {
> return new InputSource(new StringReader("<!ENTITY nbsp \" \">"));
> }
> });
> reader.setContentHandler(new DefaultHandler()
> {
> @Override
> public void characters(char[] ch, int start, int length) throws SAXException
> {
> System.out.print(new String(ch, start, length));
> }
> });
> reader.parse(new InputSource(new StringReader(XHTML_1_0_DOCTYPE+"<html><body>Hello world</body></html>")));
> System.out.println("");
> parser.reset();
> }
> }
> prints "Hello world" for the first parser invocation, "Helloworld" for all following invocations.
> When I remove the System.setProperty(...) line everything works correctly.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org