Class OMXMLStreamReaderConfiguration
OMContainer.getXMLStreamReader(boolean, OMXMLStreamReaderConfiguration).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermine whether namespace URIs returned by theXMLStreamReadershould be interned.booleanDetermine whether strict namespace preservation is enabled.voidsetNamespaceURIInterning(boolean namespaceURIInterning) Specify whether namespace URIs returned by theXMLStreamReadershould be interned.voidsetPreserveNamespaceContext(boolean preserveNamespaceContext) Specify whether the namespace context determined by the ancestors of the element should be preserved.
-
Constructor Details
-
OMXMLStreamReaderConfiguration
public OMXMLStreamReaderConfiguration()
-
-
Method Details
-
isPreserveNamespaceContext
public boolean isPreserveNamespaceContext()Determine whether strict namespace preservation is enabled. SeesetPreserveNamespaceContext(boolean)for more information about this option.- Returns:
- the current value of this option
-
setPreserveNamespaceContext
public void setPreserveNamespaceContext(boolean preserveNamespaceContext) Specify whether the namespace context determined by the ancestors of the element should be preserved. This option only applies toOMElementinstances and is disabled by default.When this option is enabled, the
XMLStreamReader.getNamespaceCount(),XMLStreamReader.getNamespacePrefix(int)andXMLStreamReader.getNamespaceURI(int)will report additional namespace declarations for theXMLStreamConstants.START_ELEMENTevent corresponding to the element on which this method is called, i.e. the root element of the resulting stream. These namespace declarations correspond to namespaces declared by the ancestors of the element and that are visible in the context of the element.More precisely, if this option is enabled, then the namespace declarations reported for the first
XMLStreamConstants.START_ELEMENTevent in the returned stream will be the same as the declarations that would be returned byOMElement.getNamespacesInScope(), with the exception that axmlns=""declaration present on the element will be preserved.This feature is useful for code that relies on the namespace declarations reported by the
XMLStreamReaderto reconstruct the namespace context (instead of using the namespace context provided byXMLStreamReader.getNamespaceContext()). An example helps to illustrate how this works. Consider the following XML message:<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <ns:echo xmlns:ns="urn:test"> <in xsi:type="xsd:string">test</in> </ns:echo> </soapenv:Body> </soapenv:Envelope>When
OMContainer.getXMLStreamReader(boolean)is invoked on theOMElementcorresponding tons:echo, only the namespace declaration for thensprefix will be reported. This may cause a problem when the caller attempts to resolve the QName valuexsd:stringof thexsi:typeattribute. If namespace context preservation is enabled, then theXMLStreamReaderreturned by this method will generate additional namespace declarations for thesoapenv,xsdandxsiprefixes. They are reported for theXMLStreamConstants.START_ELEMENTevent representing thens:echoelement.- Parameters:
preserveNamespaceContext- the value to set for this option
-
isNamespaceURIInterning
public boolean isNamespaceURIInterning()Determine whether namespace URIs returned by theXMLStreamReadershould be interned.- Returns:
- the current value of this option
-
setNamespaceURIInterning
public void setNamespaceURIInterning(boolean namespaceURIInterning) Specify whether namespace URIs returned by theXMLStreamReadershould be interned. This applies to the return values of the following methods:- Parameters:
namespaceURIInterning- the value to set for this option- See Also:
-