|
10 | 10 | import tools.jackson.databind.deser.DeserializationContextExt;
|
11 | 11 | import tools.jackson.databind.deser.DeserializerCache;
|
12 | 12 | import tools.jackson.databind.deser.DeserializerFactory;
|
| 13 | +import tools.jackson.dataformat.xml.XmlFactory; |
13 | 14 |
|
14 | 15 | /**
|
15 | 16 | * XML-specific {@link DeserializationContext} needed to override certain
|
|
18 | 19 | public class XmlDeserializationContext
|
19 | 20 | extends DeserializationContextExt
|
20 | 21 | {
|
| 22 | + private final String _xmlTextElementName; |
| 23 | + |
21 | 24 | public XmlDeserializationContext(TokenStreamFactory tsf,
|
22 | 25 | DeserializerFactory deserializerFactory, DeserializerCache cache,
|
23 | 26 | DeserializationConfig config, FormatSchema schema,
|
24 | 27 | InjectableValues values) {
|
25 | 28 | super(tsf, deserializerFactory, cache,
|
26 | 29 | config, schema, values);
|
| 30 | + _xmlTextElementName = ((XmlFactory) tsf).getXMLTextElementName(); |
27 | 31 | }
|
28 | 32 |
|
29 | 33 | /*
|
@@ -63,12 +67,12 @@ public String extractScalarFromObject(JsonParser p, ValueDeserializer<?> deser,
|
63 | 67 | // Couple of ways to find "real" textual content. One is to look for
|
64 | 68 | // "XmlText"... but for that would need to know configuration. Alternatively
|
65 | 69 | // 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 |
68 | 72 | final String propName = p.currentName();
|
69 | 73 | JsonToken t = p.nextToken();
|
70 | 74 | if (t == JsonToken.VALUE_STRING) {
|
71 |
| - if (FromXmlParser.DEFAULT_TEXT_PROPERTY.equals(propName)) { |
| 75 | + if (propName.equals(_xmlTextElementName)) { |
72 | 76 | text = p.getString();
|
73 | 77 | }
|
74 | 78 | } else {
|
|
0 commit comments