@@ -173,7 +173,8 @@ public int next() throws XMLStreamException
173
173
System.out.printf(" XmlTokenStream.next(): XML_START_ELEMENT '%s' %s\n", _localName, _loc());
174
174
break;
175
175
case XML_END_ELEMENT:
176
- System.out.printf(" XmlTokenStream.next(): XML_END_ELEMENT '%s' %s\n", _localName, _loc());
176
+ // 24-May-2020, tatu: no name available for end element so do not print
177
+ System.out.printf(" XmlTokenStream.next(): XML_END_ELEMENT %s\n", _loc());
177
178
break;
178
179
case XML_ATTRIBUTE_NAME:
179
180
System.out.printf(" XmlTokenStream.next(): XML_ATTRIBUTE_NAME '%s' %s\n", _localName, _loc());
@@ -219,7 +220,15 @@ public void skipEndElement() throws IOException, XMLStreamException
219
220
public int getCurrentToken () { return _currentState ; }
220
221
221
222
public String getText () { return _textValue ; }
223
+
224
+ /**
225
+ * Accessor for local name of current named event (that is,
226
+ * {@code XML_START_ELEMENT} or {@code XML_ATTRIBUTE_NAME}).
227
+ *<p>
228
+ * NOTE: name NOT accessible on {@code XML_END_ELEMENT}
229
+ */
222
230
public String getLocalName () { return _localName ; }
231
+
223
232
public String getNamespaceURI () { return _namespaceURI ; }
224
233
225
234
public boolean hasXsiNil () {
@@ -509,27 +518,17 @@ private final String _getText(XMLStreamReader2 r) throws XMLStreamException
509
518
/**********************************************************************
510
519
*/
511
520
512
- /*
513
- _xmlReader = Stax2ReaderAdapter.wrapIfNecessary(xmlReader);
514
- _currentState = XML_START_ELEMENT;
515
- _localName = _xmlReader.getLocalName();
516
- _namespaceURI = _xmlReader.getNamespaceURI();
517
- _attributeCount = _xmlReader.getAttributeCount();
518
- _formatFeatures = formatFeatures;
519
- */
520
-
521
521
private final int _initStartElement () throws XMLStreamException
522
522
{
523
523
final String ns = _xmlReader .getNamespaceURI ();
524
524
final String localName = _xmlReader .getLocalName ();
525
525
526
526
_checkXsiAttributes ();
527
527
528
- /* Support for virtual wrapping: in wrapping, may either
529
- * create a new wrapper scope (if in sub-tree, or matches
530
- * wrapper element itself), or implicitly close existing
531
- * scope.
532
- */
528
+ // Support for virtual wrapping: in wrapping, may either create a new
529
+ // wrapper scope (if in sub-tree, or matches wrapper element itself),
530
+ // or implicitly close existing scope.
531
+
533
532
if (_currentWrapper != null ) {
534
533
if (_currentWrapper .matchesWrapper (localName , ns )) {
535
534
_currentWrapper = _currentWrapper .intermediateWrapper ();
@@ -631,11 +630,21 @@ private final int _handleEndElement()
631
630
//System.out.println(" XMLTokenStream._handleEndElement(): IMPLICIT requestRepeat of END_ELEMENT '"+_localName);
632
631
} else {
633
632
_currentWrapper = _currentWrapper .getParent ();
633
+ // 23-May-2020, tatu: Let's clear _localName since it's value is unlikely
634
+ // to be correct and we may or may not be able to get real one (for
635
+ // END_ELEMENT could) -- FromXmlParser does NOT use this info
636
+ _localName = "" ;
637
+ _namespaceURI = "" ;
638
+
634
639
}
640
+ } else {
641
+ // Not (necessarily) known, as per above, so:
642
+ _localName = "" ;
643
+ _namespaceURI = "" ;
635
644
}
636
645
return (_currentState = XML_END_ELEMENT );
637
646
}
638
-
647
+
639
648
private JsonLocation _extractLocation (XMLStreamLocation2 location )
640
649
{
641
650
if (location == null ) { // just for impls that might pass null...
@@ -647,7 +656,6 @@ private JsonLocation _extractLocation(XMLStreamLocation2 location)
647
656
location .getColumnNumber ());
648
657
}
649
658
650
-
651
659
protected boolean _allWs (String str )
652
660
{
653
661
final int len = (str == null ) ? 0 : str .length ();
0 commit comments