diff --git a/commons-serialize-xml/src/main/java/io/gitlab/jfronny/commons/serialize/xml/wrapper/XmlReader.java b/commons-serialize-xml/src/main/java/io/gitlab/jfronny/commons/serialize/xml/wrapper/XmlReader.java index 4243ad4..46b3f29 100644 --- a/commons-serialize-xml/src/main/java/io/gitlab/jfronny/commons/serialize/xml/wrapper/XmlReader.java +++ b/commons-serialize-xml/src/main/java/io/gitlab/jfronny/commons/serialize/xml/wrapper/XmlReader.java @@ -29,7 +29,8 @@ public class XmlReader extends SerializeReader implement private static final int PEEKED_CDATA = 11; private static final int PEEKED_NAME_VIRTUAL_TEXT = 12; private static final int PEEKED_NAME_VIRTUAL_CDATA = 13; - private static final int PEEKED_EOF = 14; + private static final int PEEKED_NULL_VIRTUAL = 14; + private static final int PEEKED_EOF = 15; int peeked = PEEKED_NONE; private final NativeXmlReader reader; @@ -43,7 +44,7 @@ public class XmlReader extends SerializeReader implement private String nextTagName = null; { - stack[stackSize++] = WrapperScope.DOCUMENT; + push(WrapperScope.DOCUMENT); } private void push(int newTop) { @@ -66,6 +67,7 @@ public class XmlReader extends SerializeReader implement @Override public XmlReader setLenient(boolean lenient) { + super.setLenient(lenient); reader.setLenient(lenient); return this; } @@ -175,6 +177,7 @@ public class XmlReader extends SerializeReader implement case PEEKED_CDATA -> heuristics.guessValueKind(getPath(), XmlToken.CDATA); case PEEKED_ATT_VALUE -> heuristics.guessValueKind(getPath(), XmlToken.ATTRIBUTE_VALUE); case PEEKED_TEXT -> heuristics.guessValueKind(getPath(), XmlToken.TEXT); + case PEEKED_NULL_VIRTUAL -> Token.NULL; case PEEKED_EOF -> Token.END_DOCUMENT; default -> throw new AssertionError(); }; @@ -259,6 +262,11 @@ public class XmlReader extends SerializeReader implement reader.endTag(); yield doPeek(); } + case WrapperScope.OBJECT_VALUE_WRAPPER -> { + stackSize--; + reader.endTag(); + yield PEEKED_NULL_VIRTUAL; + } default -> throw syntaxError("Unexpected end tag"); }; case EOF -> PEEKED_EOF; @@ -373,6 +381,7 @@ public class XmlReader extends SerializeReader implement } yield reader.nextCData(); } + case PEEKED_NULL_VIRTUAL -> "null"; default -> throw unexpectedTokenError(kind); }; peeked = PEEKED_NONE;