5
5
import javax .xml .XMLConstants ;
6
6
import javax .xml .stream .*;
7
7
8
- import com .fasterxml .jackson .dataformat .xml .XmlNameProcessor ;
9
8
import org .codehaus .stax2 .XMLStreamLocation2 ;
10
9
import org .codehaus .stax2 .XMLStreamReader2 ;
11
- import org .codehaus .stax2 .ri .Stax2ReaderAdapter ;
12
10
13
11
import com .fasterxml .jackson .core .JsonLocation ;
14
12
import com .fasterxml .jackson .core .io .ContentReference ;
15
13
14
+ import com .fasterxml .jackson .dataformat .xml .XmlNameProcessor ;
15
+ import com .fasterxml .jackson .dataformat .xml .util .Stax2JacksonReaderAdapter ;
16
+
16
17
/**
17
18
* Simple helper class used on top of STAX {@link XMLStreamReader} to further
18
19
* abstract out all irrelevant details, and to expose equivalent of flat token
@@ -168,7 +169,8 @@ public XmlTokenStream(XMLStreamReader xmlReader, ContentReference sourceRef,
168
169
_sourceReference = sourceRef ;
169
170
_formatFeatures = formatFeatures ;
170
171
_cfgProcessXsiNil = FromXmlParser .Feature .PROCESS_XSI_NIL .enabledIn (_formatFeatures );
171
- _xmlReader = Stax2ReaderAdapter .wrapIfNecessary (xmlReader );
172
+ // 04-Dec-2023, tatu: [dataformat-xml#618] Need further customized adapter:
173
+ _xmlReader = Stax2JacksonReaderAdapter .wrapIfNecessary (xmlReader );
172
174
_nameProcessor = nameProcessor ;
173
175
}
174
176
@@ -557,14 +559,15 @@ private final String _collectUntilTag() throws XMLStreamException
557
559
}
558
560
559
561
CharSequence chars = null ;
560
- while (true ) {
562
+ main_loop :
563
+ while (_xmlReader .hasNext ()) {
561
564
switch (_xmlReader .next ()) {
562
565
case XMLStreamConstants .START_ELEMENT :
563
- return ( chars == null ) ? "" : chars . toString () ;
566
+ break main_loop ;
564
567
565
568
case XMLStreamConstants .END_ELEMENT :
566
569
case XMLStreamConstants .END_DOCUMENT :
567
- return ( chars == null ) ? "" : chars . toString () ;
570
+ break main_loop ;
568
571
569
572
// note: SPACE is ignorable (and seldom seen), not to be included
570
573
case XMLStreamConstants .CHARACTERS :
@@ -586,6 +589,7 @@ private final String _collectUntilTag() throws XMLStreamException
586
589
// any other type (proc instr, comment etc) is just ignored
587
590
}
588
591
}
592
+ return (chars == null ) ? "" : chars .toString ();
589
593
}
590
594
591
595
// Called to skip tokens until start/end tag (or end-of-document) found, but
0 commit comments