Preserving CDATA sections - AXIOM StAX parsing
In XML CDATA sections provide a way to tell the parser that there is no markup in the characters contained by the CDATA section. And that makes it much easier to create documents containing sections where markup characters might appear, but where no markup is intended. CDATA is commonly used for scripting language content and sample XML/HTML content.
So in context of Web Services with Apache Axis, the default settings of the AXIOM StAX parser would ignore the CDATA sections and won't preserve them after the parsing is done. In coalescing mode, the parser will not only coalescing adjacent text nodes, but also CDATA sections.
However there are cases that you need to preserve CDATA section after parsing and creating OMElement. So, in such a scenario you need to switch off the coalescing mode by setting a property in XMLInputFactory. (i.e.: "javax.xml.stream.isCoalescing" = false). The following code will create an AXIOM OMElement with preserving CDATA.
For detailed overview of Axiom please refer Andreas' Axiom User Guide.
So in context of Web Services with Apache Axis, the default settings of the AXIOM StAX parser would ignore the CDATA sections and won't preserve them after the parsing is done. In coalescing mode, the parser will not only coalescing adjacent text nodes, but also CDATA sections.
However there are cases that you need to preserve CDATA section after parsing and creating OMElement. So, in such a scenario you need to switch off the coalescing mode by setting a property in XMLInputFactory. (i.e.: "javax.xml.stream.isCoalescing" = false). The following code will create an AXIOM OMElement with preserving CDATA.
For detailed overview of Axiom please refer Andreas' Axiom User Guide.
Comentários
Postar um comentário