Java 教程是为 JDK 8 编写的。本页中描述的示例和实践未利用在后续版本中引入的改进。
The specification for StAX, JSR 173, does not yet support the new properties. However, StAX in the context of JAXP does include the support of these properties. Setting the new properties is similar to SAX or DOM, but through the XMLInputFactory as follows:
XMLInputFactory xif = XMLInputFactory.newInstance(); xif.setProperty("http://javax.xml.XMLConstants/property/accessExternalDTD", "file");
The existing properties and features specified in the StAX, JSR 173 specification will take preference over the new JAXP properties. The SupportDTD property for example, when set to false, will cause a program to throw exception when an input file contains DTD before it can be parsed. For applications that uses the SupportDTD property to disable DTD therefore, the addition of the new properties shall have no effect.