jackson-dataformat-xml icon indicating copy to clipboard operation
jackson-dataformat-xml copied to clipboard

Custom deserialization logic not reporting CDATA events

Open mmkathurima opened this issue 8 months ago • 15 comments

Using the following code:

@Override
public XmlNode deserialize(JsonParser p, DeserializationContext ctxt) {
    if (p instanceof FromXmlParser) {
        XMLStreamReader reader = ((FromXmlParser) p).getStaxReader();
        while (reader.hasNext()) {
             switch (reader.next()) {
                 case XMLStreamConstants.CDATA:
                     System.out.println("Found CDATA");
                     break;
             }
         }
     }
}

The CDATA branch is never reached. Even after enabling the P_REPORT_CDATA and disabling the IS_COALESCING flags:

XMLInputFactory xmlInputFactory = new WstxInputFactory();
xmlInputFactory.setProperty(XMLInputFactory2.P_REPORT_CDATA, Boolean.TRUE);
xmlInputFactory.setProperty(XMLInputFactory2.IS_COALESCING, Boolean.FALSE);
XmlMapper xmlMapper = new XmlMapper(xmlInputFactory);

mmkathurima avatar Apr 13 '25 11:04 mmkathurima