FasterXML / FasterXML/jackson-dataformat-xml
Attribute / element name collision (same local name, different namepace) cannot be configured during deserialization
- Dominant language
- Java
- Stars
- 631
- Forks
- 246
- Avg merge
- 7d 9h
- Merged PRs (30d)
- 13
Description
If an element has an attribute and sub-element with the same name, the attribute seems to be ignored and the element value used, despite collision resolving configuration with `@JacksonXmlProperty(localName="state", isAttribute=true)` (for colliding name `state`). Here is concrete example
``` java
static class TwoStates {
@JacksonXmlProperty(localName="state", isAttribute=true)
public String stateAttr = "NOT SET";
public String state = "NOT SET";
}
```
The following input should deserialize the appropriate distinct values into the appropriate distinct fields:
`stateElement`
Here is a failing test snippet for `com.fasterxml.jackson.dataformat.xml.failing.TestDeserialization`
``` java
private static class TwoStates
{
@JacksonXmlProperty(localName="state", isAttribute=true)
public String stateAttr = "NOT SET";
public String state = "NOT SET";
@Override public String toString() { return "TwoStates: stateAttr: " + stateAttr + " state: " + state; }
}
public void testAttrElementConflict() throws Exception
{
TwoStates ob = MAPPER.readValue("stateElement",
TwoStates.class);
assertNotNull(ob);
System.err.println("ob: " + ob);
assertEquals("stateElement", ob.state);
assertEquals("stateAttr", ob.stateAttr); // attribute stateAttr is ignored so this fails
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.