Skip to content

XStreamMarshaller: Can't parse XML with '_' in the attribute names [SPR-11702] #16324

@spring-projects-issues

Description

@spring-projects-issues

Nil opened SPR-11702 and commented

There is no way from XStreamMarshaller to inject the custom NameCoder in the call to create StaxReader.

Details:
XStream uses '' as the escape character. For the XML files with " _ " as names it's unable to parse fields as XStream converts the "x_x" names into "x _x".

The work around for XStream is use custom NameCoder.

XStreamMarshaller wraps the call to create a StaxReader as follows:

@Override
protected Object unmarshalXmlStreamReader(XMLStreamReader streamReader) throws XmlMappingException {
    return doUnmarshal(new StaxReader(new QNameMap(), streamReader), null);
}

This causes the default StaxReader to get created with XMLFriendlyNameCoder.

public StaxReader(QNameMap qnameMap, XMLStreamReader in) {
    this(qnameMap, in, new XmlFriendlyNameCoder());
}

Affects: 4.0.3

Referenced from: commits 090ab4b, f5cce14

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions