@@ -170,28 +170,33 @@ public int next() throws XMLStreamException
170
170
int n = next0();
171
171
switch (n) {
172
172
case XML_START_ELEMENT:
173
- System.out.println (" XmlTolenStream .next(): XML_START_ELEMENT '"+_localName+"'" );
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.println (" XmlTolenStream .next(): XML_END_ELEMENT '"+_localName+"'" );
176
+ System.out.printf (" XmlTokenStream .next(): XML_END_ELEMENT '%s' %s\n", _localName, _loc() );
177
177
break;
178
178
case XML_ATTRIBUTE_NAME:
179
- System.out.println (" XmlTolenStream .next(): XML_ATTRIBUTE_NAME '"+_localName+"'" );
179
+ System.out.printf (" XmlTokenStream .next(): XML_ATTRIBUTE_NAME '%s' %s\n", _localName, _loc() );
180
180
break;
181
181
case XML_ATTRIBUTE_VALUE:
182
- System.out.println (" XmlTolenStream .next(): XML_ATTRIBUTE_VALUE '"+_textValue+"'" );
182
+ System.out.printf (" XmlTokenStream .next(): XML_ATTRIBUTE_VALUE '%s' %s\n", _textValue, _loc() );
183
183
break;
184
184
case XML_TEXT:
185
- System.out.println (" XmlTolenStream .next(): XML_TEXT '"+_textValue+"'" );
185
+ System.out.printf (" XmlTokenStream .next(): XML_TEXT '%s' %s\n", _textValue, _loc() );
186
186
break;
187
187
case XML_END:
188
- System.out.println (" XmlTolenStream .next(): XML_END" );
188
+ System.out.printf (" XmlTokenStream .next(): XML_END %s\n", _loc() );
189
189
break;
190
190
default:
191
191
throw new IllegalStateException();
192
192
}
193
193
return n;
194
194
}
195
+
196
+ private String _loc() {
197
+ JsonLocation loc = getCurrentLocation();
198
+ return String.format("[line: %d, column: %d]", loc.getLineNr(), loc.getColumnNr());
199
+ }
195
200
*/
196
201
197
202
// public int next0() throws XMLStreamException
@@ -252,14 +257,17 @@ public JsonLocation getTokenLocation() {
252
257
/**
253
258
* Method used to add virtual wrapping, which just duplicates START_ELEMENT
254
259
* stream points to, and its matching closing element.
255
- *
256
- * @since 2.1
257
260
*/
258
261
protected void repeatStartElement ()
259
262
{
260
263
//System.out.println(" -> repeatStartElement for "+_localName+", _currentWrapper was: "+_currentWrapper);
261
264
// sanity check: can only be used when just returned START_ELEMENT:
262
265
if (_currentState != XML_START_ELEMENT ) {
266
+ // 14-May-2020, tatu: Looks like we DO end up here with empty Lists; if so,
267
+ // should NOT actually wrap.
268
+ if (_currentState == XML_END_ELEMENT ) {
269
+ return ;
270
+ }
263
271
throw new IllegalStateException ("Current state not XML_START_ELEMENT ("
264
272
+XML_START_ELEMENT +") but " +_currentState );
265
273
}
0 commit comments