java.lang.Object
dev.metaschema.databind.io.xml.XmlDomUtil
Utility methods for converting between StAX events and W3C DOM elements.
These methods support the any content feature by converting unmodeled
XML content between the StAX event stream used during parsing and the DOM
representation stored in XmlAnyContent.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidelementToStax(Element element, org.codehaus.stax2.XMLStreamWriter2 writer) Write a DOMElementto a StAX stream writer.static ElementstaxToElement(org.codehaus.stax2.XMLEventReader2 reader) Read an XML element from a StAX event reader and return it as a DOMElement.
-
Method Details
-
staxToElement
@NonNull public static Element staxToElement(@NonNull org.codehaus.stax2.XMLEventReader2 reader) throws XMLStreamException Read an XML element from a StAX event reader and return it as a DOMElement.The reader must be positioned so that the next event is a
XMLStreamConstants.START_ELEMENT. After this method returns, the reader will be positioned just past the matchingXMLStreamConstants.END_ELEMENT.- Parameters:
reader- the StAX event reader, positioned before a start element- Returns:
- the DOM element containing the full subtree
- Throws:
XMLStreamException- if an error occurs while reading XML events
-
elementToStax
public static void elementToStax(@NonNull Element element, @NonNull org.codehaus.stax2.XMLStreamWriter2 writer) throws XMLStreamException Write a DOMElementto a StAX stream writer.This writes the complete element subtree including attributes, namespace declarations, child elements, and text content.
- Parameters:
element- the DOM element to writewriter- the StAX stream writer to write to- Throws:
XMLStreamException- if an error occurs while writing to the stream
-