In addition to bugs in particular StAX implementations and clear violations of the StAX specifications, the following ambiguities and gray areas in the specifications are also addressed by the dialect implementations:
null
value for the charset encoding parameter in the following methods: null
values, while others throw an exception. To make sure that code written to run with a normalized {@link XMLOutputFactory} remainsportable, the dialect implementation normalizes the behavior of these methods so that they consistently throw an exception when called with a null
encoding. Note that the type of exception to be thrown remains unspecified.null
if unknown". This requirement is not precise enough to guarantee consistent behavior across different implementations. In order to provide the consumer of the stream reader with complete and unambiguous information about the encoding of the underlying stream, the dialect implementations normalize the behavior of the {@link javax.xml.stream.XMLStreamReader#getEncoding()} method such thatit returns a non null value if and only if the reader was created from a byte stream, in which case the return value is the effective charset encoding used by the parser to decode the byte stream. According to the XML specifications, this value is determined by one of the following means: true
if and only if the current event is {@link javax.xml.stream.XMLStreamConstants#CHARACTERS}. This is the case for most parsers, but some return true
for {@link javax.xml.stream.XMLStreamConstants#SPACE}events as well. Where necessary, the dialect implementations correct this behavior. Note that there are several ambiguities in the StAX specification which are not addressed by the different dialect implementations:
null
or an empty string if the attribute doesn't have a prefix. Consistency with {@link javax.xml.stream.XMLStreamReader#getPrefix()} wouldimply that it should return null
, but some implementations return an empty string.Note that some implementations (including the reference implementation) throw an {@link javax.xml.stream.XMLStreamException} in this case. This is considered as aviolation of the specifications because this exception should only be used "if there is an error processing the underlying XML source", which is not the case.
null
or an empty string.writeStartElement
and writeEndElement
methods. On the other hand, the requirement is ambiguous in the context of an element written using writeEmptyElement
and there are two competing interpretations: writeEmptyElement
methods actually doesn't write a complete element because it can be followed by invocations of writeAttribute
, writeNamespace
or writeDefaultNamespace
. The element is only completed by a call to a write
method other than the aforementioned methods. An element written using writeEmptyElement
therefore also defines a scope and the namespace should be bound in that scope.writeEmptyElement
, writeAttribute
, setPrefix
, writeCharacters
. In this case, it is not clear if the scope of the empty element should end at the call to writeAttribute
or writeCharacters
. Because of these ambiguities, the dialect implementations don't attempt to normalize the behavior of {@link javax.xml.stream.XMLStreamWriter#setPrefix(String,String)}and {@link javax.xml.stream.XMLStreamWriter#setDefaultNamespace(String)} in this particularcontext, and their usage in conjunction with writeEmptyElement
should be avoided.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|