Print
Extensions

Clarifications

In non-namespace aware mode one should expect getLocalName() to return qname and use getAttributeValue() to pass null namespace (namespaceURI) and null namespaceURI and locaName as qname (localName) to getAttributeValue(java.lang.String namespaceURI, java.lang.String localName)

Unofficial Extensions

Rationale

The biggest reason for adding this functionality is to allow for round-tripping of basic document type declaration information: currently this is not possible to do without using implementation specific functionality.

And using XMLStreamReader.getProperty() seems like the only backwards compatible (and gracefully failing) wait to do this: no new methods need to be added, and implementations that do not support these features can return null (Stax javadocs do not indicate that an exception should be thrown for unknown properties; it may be possible that some implementations might consider throwing an IllegalArgumentException).

DTD support extensions proposed for JSR 280

While in DTD event JSR-173 implementation returns:

  • javax.xml.stream.dtd.declaration

    StAX property to retrieve document type declaration as a String. This retrieves the same information as the dtdRootElement, publicId and systemId properties proposed below as a single string.
  • javax.xml.stream.dtdRootElement for accessing the

    root declaration (qname, since there is no way to bind the namespace, even if there is one)
  • javax.xml.stream.publicId for accessing the public identifier (if available)
  • javax.xml.stream.systemId for accessing the system identifier (if available)

List properties accessed as String[] l = (String[]) getProperty("javax.xml.stream.notations");

  • javax.xml.stream.dtd.processingInstructions

    StAX property to retrieve processing instructions in a DTD. (This is also an XML conformance issue)
  • javax.xml.stream.dtd.comments

    StAX property to retrieve comments in a DTD. Added more for symmetry with the previous property than anything else.
  • javax.xml.stream.entities

    NOTE: entity names and public identifiers are interleaved in the list: name, public identifier, name, public identifier ...?
  • javax.xml.stream.notations

    NOTE: entity names, public and system identifiers are interleaved

An alternative is to split:

  • javax.xml.stream.entity.names' property (String[])
  • javax.xml.stream.entity.publicIds' property (String[])
  • javax.xml.stream.notation.names' property (String[])
  • javax.xml.stream.notation.publicIds' property (String[])
  • javax.xml.stream.notation.systemIds' property (String[])

Additional DTD support (beyond JSR 280)

"javax.xml.stream.dtd.resolveURIs"

StAX property to control DTD URI expansion. Also needed

for conformance testing since portable expected results

data files don't embed absolute path names to the test

documents.

Powered by Atlassian Confluence