@@ -35,7 +35,7 @@ public class XmlTokenStream
35
35
36
36
// New in 2.12: needed to "re-process" previously encountered START_ELEMENT,
37
37
// with possible leading text
38
- public final static int XML_DELAYED_START_ELEMENT = 6 ;
38
+ // public final static int XML_DELAYED_START_ELEMENT = 6;
39
39
40
40
// 2.12 also exposes "root scalars" as-is, instead of wrapping as Objects; this
41
41
// needs some more state management too
@@ -180,11 +180,26 @@ public int initialize() throws XMLStreamException
180
180
181
181
// 02-Jul-2020, tatu: Two choices: if child elements OR attributes, expose
182
182
// as Object value; otherwise expose as Text
183
- if (_xsiNilFound || _attributeCount > 0 ) {
184
- return (_currentState = XML_START_ELEMENT );
183
+ // 06-Sep-2022, tatu: Actually expose as Object in almost every situation
184
+ // as of 2.14: otherwise we have lots of issues with empty POJOs,
185
+ // Lists, Maps
186
+ if (_xmlReader .isEmptyElement ()
187
+ && FromXmlParser .Feature .EMPTY_ELEMENT_AS_NULL .enabledIn (_formatFeatures )
188
+ && !_xsiNilFound
189
+ && _attributeCount < 1 ) {
190
+ // 06-Sep-2022, tatu: In fact the only special case of null conversion
191
+ // of the root empty element
192
+ _textValue = null ;
193
+ _startElementAfterText = false ;
194
+ return (_currentState = XML_ROOT_TEXT );
185
195
}
196
+ return (_currentState = XML_START_ELEMENT );
197
+
198
+ // 06-Sep-2022, tatu: This code was used in 2.12, 2.13, may be
199
+ // removed after 2.14 if/when no longer needed
186
200
187
201
// copied from START_ELEMENT section of _next():
202
+ /*
188
203
final String text = _collectUntilTag();
189
204
if (text == null) {
190
205
// 30-Nov-2020, tatu: [dataformat-xml#435], this is tricky
@@ -208,6 +223,7 @@ public int initialize() throws XMLStreamException
208
223
_startElementAfterText = false;
209
224
_textValue = text;
210
225
return (_currentState = XML_ROOT_TEXT);
226
+ */
211
227
}
212
228
213
229
public XMLStreamReader2 getXmlReader () {
@@ -396,9 +412,12 @@ protected void skipAttributes()
396
412
break ;
397
413
case XML_TEXT :
398
414
break ; // nothing to do... is it even legal?
415
+
416
+ /*
399
417
case XML_DELAYED_START_ELEMENT:
400
418
// 03-Jul-2020, tatu: and here nothing to do either... ?
401
419
break;
420
+ */
402
421
default :
403
422
throw new IllegalStateException (
404
423
"Current state not XML_START_ELEMENT or XML_ATTRIBUTE_NAME but " +_currentStateDesc ());
@@ -459,6 +478,7 @@ private final int _next() throws XMLStreamException
459
478
_startElementAfterText = false ;
460
479
return _handleEndElement ();
461
480
481
+ /*
462
482
case XML_DELAYED_START_ELEMENT: // since 2.12, to support scalar Root Value
463
483
// Two cases: either "simple" with not text
464
484
if (_textValue == null) {
@@ -468,6 +488,7 @@ private final int _next() throws XMLStreamException
468
488
// then followed by start element
469
489
_startElementAfterText = true;
470
490
return (_currentState = XML_TEXT);
491
+ */
471
492
472
493
case XML_ATTRIBUTE_NAME :
473
494
// if we just returned name, will need to just send value next
@@ -785,8 +806,8 @@ protected String _stateDesc(int state) {
785
806
return "XML_ATTRIBUTE_VALUE" ;
786
807
case XML_TEXT :
787
808
return "XML_TEXT" ;
788
- case XML_DELAYED_START_ELEMENT :
789
- return "XML_START_ELEMENT_DELAYED" ;
809
+ // case XML_DELAYED_START_ELEMENT:
810
+ // return "XML_START_ELEMENT_DELAYED";
790
811
case XML_ROOT_TEXT :
791
812
return "XML_ROOT_TEXT" ;
792
813
case XML_END :
0 commit comments