@@ -75,6 +75,9 @@ public class XmlTokenStream
75
75
76
76
protected boolean _cfgProcessXsiNil ;
77
77
78
+ // @since 2.17
79
+ protected boolean _cfgProcessXsiType ;
80
+
78
81
protected XmlNameProcessor _nameProcessor ;
79
82
80
83
/*
@@ -169,6 +172,7 @@ public XmlTokenStream(XMLStreamReader xmlReader, ContentReference sourceRef,
169
172
_sourceReference = sourceRef ;
170
173
_formatFeatures = formatFeatures ;
171
174
_cfgProcessXsiNil = FromXmlParser .Feature .PROCESS_XSI_NIL .enabledIn (_formatFeatures );
175
+ _cfgProcessXsiType = FromXmlParser .Feature .AUTO_DETECT_XSI_TYPE .enabledIn (_formatFeatures );
172
176
// 04-Dec-2023, tatu: [dataformat-xml#618] Need further customized adapter:
173
177
_xmlReader = Stax2JacksonReaderAdapter .wrapIfNecessary (xmlReader );
174
178
_nameProcessor = nameProcessor ;
@@ -247,6 +251,7 @@ public XMLStreamReader2 getXmlReader() {
247
251
protected void setFormatFeatures (int f ) {
248
252
_formatFeatures = f ;
249
253
_cfgProcessXsiNil = FromXmlParser .Feature .PROCESS_XSI_NIL .enabledIn (f );
254
+ _cfgProcessXsiType = FromXmlParser .Feature .AUTO_DETECT_XSI_TYPE .enabledIn (f );
250
255
}
251
256
252
257
/*
@@ -517,7 +522,6 @@ private final int _next() throws XMLStreamException
517
522
return (_currentState = XML_END );
518
523
case XML_END :
519
524
return XML_END ;
520
- // throw new IllegalStateException("No more XML tokens available (end of input)");
521
525
}
522
526
// Ok: must be END_ELEMENT; see what tag we get (or end)
523
527
switch (_skipAndCollectTextUntilTag ()) {
@@ -712,6 +716,15 @@ private final void _checkXsiAttributes() {
712
716
* @since 2.14
713
717
*/
714
718
protected void _decodeElementName (String namespaceURI , String localName ) {
719
+ // 31-Jan-2024, tatu: [dataformat-xml#634] Need to convert 'xsi:type'?
720
+ // (not 100% sure if needed for elements but let's do for now)
721
+ if (_cfgProcessXsiType ) {
722
+ if (localName .equals ("type" ) && XSI_NAMESPACE .equals (namespaceURI )) {
723
+ _localName = "xsi:type" ;
724
+ _namespaceURI = "" ; // or could leave as it was?
725
+ return ;
726
+ }
727
+ }
715
728
_nameToDecode .namespace = namespaceURI ;
716
729
_nameToDecode .localPart = localName ;
717
730
_nameProcessor .decodeName (_nameToDecode );
@@ -723,6 +736,14 @@ protected void _decodeElementName(String namespaceURI, String localName) {
723
736
* @since 2.14
724
737
*/
725
738
protected void _decodeAttributeName (String namespaceURI , String localName ) {
739
+ // 31-Jan-2024, tatu: [dataformat-xml#634] Need to convert 'xsi:type'?
740
+ if (_cfgProcessXsiType ) {
741
+ if (localName .equals ("type" ) && XSI_NAMESPACE .equals (namespaceURI )) {
742
+ _localName = "xsi:type" ;
743
+ _namespaceURI = "" ; // or could leave as it was?
744
+ return ;
745
+ }
746
+ }
726
747
_nameToDecode .namespace = namespaceURI ;
727
748
_nameToDecode .localPart = localName ;
728
749
_nameProcessor .decodeName (_nameToDecode );
0 commit comments