Skip to content

Commit feaf2e8

Browse files
committed
Merge branch '3.x' into feature/record-with-jacksonxmltext
2 parents 2e8e2b5 + cad7739 commit feaf2e8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/java/tools/jackson/dataformat/xml/deser/XmlDeserializationContext.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import tools.jackson.databind.deser.DeserializationContextExt;
1111
import tools.jackson.databind.deser.DeserializerCache;
1212
import tools.jackson.databind.deser.DeserializerFactory;
13+
import tools.jackson.dataformat.xml.XmlFactory;
1314

1415
/**
1516
* XML-specific {@link DeserializationContext} needed to override certain
@@ -18,12 +19,15 @@
1819
public class XmlDeserializationContext
1920
extends DeserializationContextExt
2021
{
22+
private final String _xmlTextElementName;
23+
2124
public XmlDeserializationContext(TokenStreamFactory tsf,
2225
DeserializerFactory deserializerFactory, DeserializerCache cache,
2326
DeserializationConfig config, FormatSchema schema,
2427
InjectableValues values) {
2528
super(tsf, deserializerFactory, cache,
2629
config, schema, values);
30+
_xmlTextElementName = ((XmlFactory) tsf).getXMLTextElementName();
2731
}
2832

2933
/*
@@ -63,12 +67,12 @@ public String extractScalarFromObject(JsonParser p, ValueDeserializer<?> deser,
6367
// Couple of ways to find "real" textual content. One is to look for
6468
// "XmlText"... but for that would need to know configuration. Alternatively
6569
// could hold on to last text seen -- but this might be last attribute, for
66-
// empty element. So for now let's simply hard-code check for empty String
67-
// as marker and hope for best
70+
// empty element. So for now let's simply hard-code check for expected
71+
// "text element" marker/placeholder and hope for best
6872
final String propName = p.currentName();
6973
JsonToken t = p.nextToken();
7074
if (t == JsonToken.VALUE_STRING) {
71-
if (FromXmlParser.DEFAULT_TEXT_PROPERTY.equals(propName)) {
75+
if (propName.equals(_xmlTextElementName)) {
7276
text = p.getString();
7377
}
7478
} else {

0 commit comments

Comments
 (0)