-
Bug
-
Resolution: Fixed
-
P3
-
9
-
b158
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8175662 | 10 | Joe Wang | P3 | Resolved | Fixed | b02 |
ParseError will happen during StAX parse the follow xml:
<?xml
version="1.0"?>
<root>
<test>t</test>
</root>
Run the following java program:
import java.io.File;
import java.io.FileReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
public class Test8169450 {
public static void main(String[] args) throws Exception {
File file = new File("test.xml");
/* DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(true);
DocumentBuilder db = dbf.newDocumentBuilder();
db.parse(file); */
XMLStreamReader reader = XMLInputFactory.newFactory().createXMLStreamReader(new FileReader(file));
while (reader.hasNext()) {
reader.next();
}
}
}
It will throw exception:
Exception in thread "main" javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,11]
Message: The processing instruction target matching "[xX][mM][lL]" is not allowed.
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:596)
at Test8169450.main(Test8169450.java:20)
This issue should be caused byJDK-8069098.
<?xml
version="1.0"?>
<root>
<test>t</test>
</root>
Run the following java program:
import java.io.File;
import java.io.FileReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
public class Test8169450 {
public static void main(String[] args) throws Exception {
File file = new File("test.xml");
/* DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(true);
DocumentBuilder db = dbf.newDocumentBuilder();
db.parse(file); */
XMLStreamReader reader = XMLInputFactory.newFactory().createXMLStreamReader(new FileReader(file));
while (reader.hasNext()) {
reader.next();
}
}
}
It will throw exception:
Exception in thread "main" javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,11]
Message: The processing instruction target matching "[xX][mM][lL]" is not allowed.
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:596)
at Test8169450.main(Test8169450.java:20)
This issue should be caused by
- backported by
-
JDK-8175662 StAX parse error if there is a newline in xml declaration
- Resolved
- relates to
-
JDK-8069098 StAX produces the wrong event stream
- Resolved
-
JDK-8238164 Update Xerces2 Java to version 2.12.0
- Resolved