-
Bug
-
Resolution: Fixed
-
P4
-
6u11
-
h1170
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2185493 | 7 | Joe Wang | P3 | Closed | Fixed | m05 |
JDK-2182549 | 6u32 | Abhijit Saha | P4 | Closed | Fixed | b01 |
OPERATING SYSTEM
----------------
Windows
FULL JDK VERSION
----------------
1.6.0_11
DESCRIPTION
-----------
I'm using the StAX XMLEventReader to read a DTD declaration. When running on the Sun JRE, I'm
observing two problems:
1. The Sun parser attempts to resolve the DTD, even though
IS_SUPPORTING_EXTERNAL_ENTITIES is explicitly set to false.
2. The call to ((javax.xml.stream.events.DTD)event).getDocumentTypeDeclaration ())
will return a useless truncated value.
Attached is DTDTest.java which will replicate this problem every time.
TESTCASE SOURCE
---------------
import javax.xml.stream.XMLStreamException;
public class DTDTest {
private static final String xml = "<!DOCTYPE html PUBLIC \"-//W3C//DTDXHTML 1.0 Transitional//EN\" "
+ "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
+ "<html><body><p>I am some simple html</p></body> </html>";
public static void main (String[] args) throws Exception {
javax.xml.stream.XMLInputFactory factory = javax.xml.stream.XMLInputFactory.newInstance ();
factory.setXMLResolver (new DTDResolver ());
factory.setProperty (javax.xml.stream.XMLInputFactory.SUPPORT_DTD, true);
factory.setProperty (javax.xml.stream.XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES , false);
java.io.ByteArrayInputStream is = new java.io.ByteArrayInputStream(xml.getBytes ("UTF-8"));
javax.xml.transform.stream.StreamSource source = new javax.xml.transform.stream.StreamSource (is);
javax.xml.stream.XMLEventReader reader = factory.createXMLEventReader (source);
while (reader.hasNext ()) {
javax.xml.stream.events.XMLEvent event = reader.nextEvent ();
if (event.getEventType () == javax.xml.stream.XMLStreamConstants.DTD)
System.out.println (((javax.xml.stream.events.DTD) event).getDocumentTypeDeclaration ());
}
}
}
class DTDResolver implements javax.xml.stream.XMLResolver {
public Object resolveEntity (String arg0, String arg1, String arg2, String arg3) throws XMLStreamException
{
System.out.println ("I should never be called");
return new java.io.ByteArrayInputStream (new byte[0]);
}
}
----------------
Windows
FULL JDK VERSION
----------------
1.6.0_11
DESCRIPTION
-----------
I'm using the StAX XMLEventReader to read a DTD declaration. When running on the Sun JRE, I'm
observing two problems:
1. The Sun parser attempts to resolve the DTD, even though
IS_SUPPORTING_EXTERNAL_ENTITIES is explicitly set to false.
2. The call to ((javax.xml.stream.events.DTD)event).getDocumentTypeDeclaration ())
will return a useless truncated value.
Attached is DTDTest.java which will replicate this problem every time.
TESTCASE SOURCE
---------------
import javax.xml.stream.XMLStreamException;
public class DTDTest {
private static final String xml = "<!DOCTYPE html PUBLIC \"-//W3C//DTDXHTML 1.0 Transitional//EN\" "
+ "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
+ "<html><body><p>I am some simple html</p></body> </html>";
public static void main (String[] args) throws Exception {
javax.xml.stream.XMLInputFactory factory = javax.xml.stream.XMLInputFactory.newInstance ();
factory.setXMLResolver (new DTDResolver ());
factory.setProperty (javax.xml.stream.XMLInputFactory.SUPPORT_DTD, true);
factory.setProperty (javax.xml.stream.XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES , false);
java.io.ByteArrayInputStream is = new java.io.ByteArrayInputStream(xml.getBytes ("UTF-8"));
javax.xml.transform.stream.StreamSource source = new javax.xml.transform.stream.StreamSource (is);
javax.xml.stream.XMLEventReader reader = factory.createXMLEventReader (source);
while (reader.hasNext ()) {
javax.xml.stream.events.XMLEvent event = reader.nextEvent ();
if (event.getEventType () == javax.xml.stream.XMLStreamConstants.DTD)
System.out.println (((javax.xml.stream.events.DTD) event).getDocumentTypeDeclaration ());
}
}
}
class DTDResolver implements javax.xml.stream.XMLResolver {
public Object resolveEntity (String arg0, String arg1, String arg2, String arg3) throws XMLStreamException
{
System.out.println ("I should never be called");
return new java.io.ByteArrayInputStream (new byte[0]);
}
}
- backported by
-
JDK-2185493 StAX XMLEventReader DTD issues
-
- Closed
-
-
JDK-2182549 StAX XMLEventReader DTD issues
-
- Closed
-