- private void setValue(final AbstractNodeDataWithSchema parent, final String value, final NamespaceContext nsContext)
- throws ParserConfigurationException, SAXException, IOException {
- Preconditions.checkArgument(parent instanceof SimpleNodeDataWithSchema, "Node %s is not a simple type",
+ private static boolean isNextEndDocument(final XMLStreamReader in) throws XMLStreamException {
+ return !in.hasNext() || in.next() == XMLStreamConstants.END_DOCUMENT;
+ }
+
+ private static boolean isAtElement(final XMLStreamReader in) {
+ return in.getEventType() == XMLStreamConstants.START_ELEMENT
+ || in.getEventType() == XMLStreamConstants.END_ELEMENT;
+ }
+
+ private static void skipUnknownNode(final XMLStreamReader in) throws XMLStreamException {
+ // in case when the unknown node and at least one of its descendant nodes have the same name
+ // we cannot properly reach the end just by checking if the current node is an end element and has the same name
+ // as the root unknown element. therefore we ignore the names completely and just track the level of nesting
+ int levelOfNesting = 0;
+ while (in.hasNext()) {
+ // in case there are text characters in an element, we cannot skip them by calling nextTag()
+ // therefore we skip them by calling next(), and then proceed to next element
+ in.next();
+ if (!isAtElement(in)) {
+ in.nextTag();
+ }
+ if (in.isStartElement()) {
+ levelOfNesting++;
+ }
+
+ if (in.isEndElement()) {
+ if (levelOfNesting == 0) {
+ break;
+ }
+
+ levelOfNesting--;
+ }
+ }
+
+ in.nextTag();
+ }
+
+
+ private void setValue(final AbstractNodeDataWithSchema<?> parent, final Object value,
+ final NamespaceContext nsContext) {
+ checkArgument(parent instanceof SimpleNodeDataWithSchema, "Node %s is not a simple type",