Skip to content

Commit

Permalink
Fix #395
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed May 14, 2020
1 parent 225d670 commit b3926a2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Some data-binding types overridden as well (ObjectMapper sub-classed as XmlMappe
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>stax2-api</artifactId>
<version>4.2</version>
<version>4.2.1</version>
<exclusions>
<exclusion>
<groupId>javax.xml.stream</groupId>
Expand All @@ -87,7 +87,7 @@ Some data-binding types overridden as well (ObjectMapper sub-classed as XmlMappe
<dependency>
<groupId>com.fasterxml.woodstox</groupId>
<artifactId>woodstox-core</artifactId>
<version>6.2.0</version>
<version>6.2.1</version>
<exclusions>
<exclusion>
<groupId>javax.xml.stream</groupId>
Expand Down
5 changes: 5 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,8 @@ Luke Korth ([email protected])

* Reported #366: XML containing xsi:nil is improperly parsed
(2.10.2)

Martin Vysny (mvysny@github)

* Reported #395: Namespace repairing generates xmlns definitions for xml: prefix (which is implicit)
(2.10.5)
4 changes: 3 additions & 1 deletion release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Project: jackson-dataformat-xml

2.10.5 (not yet released)

-
#395: Namespace repairing generates xmlns definitions for xml: prefix (which is implicit)
(reported by Martin V)
- Upgrade Woodstox dependency to 6.2.0 (minor fix to namespace binding)

2.10.4 (03-May-2020)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,41 @@ public void setName(String name) {
this.name = name;
}
}


static class Issue395 {
@JacksonXmlProperty(isAttribute = true, namespace = "http://www.w3.org/XML/1998/namespace",
localName = "lang")
public String lang = "en-US";
}

/*
/**********************************************************
/* Unit tests
/**********************************************************
*/

// [Issue-26]: should prefer the "default namespace"

private final XmlMapper MAPPER = newMapper();

// [dataformat-xml#26]: should prefer the "default namespace"
public void testRootNamespace() throws Exception
{
Person person = new Person();
person.setName( "hello" );

XmlMapper xmlMapper = new XmlMapper();
String xml = xmlMapper.writeValueAsString(person);
String xml = MAPPER.writeValueAsString(person);

// should use "the default namespace"...
final String PREFIX = "<person xmlns=";
if (!xml.startsWith(PREFIX)) {
fail("Expected XML to begin with '"+PREFIX+"', instead got: "+xml);
}
}

// [dataformat-xml#395]: should not bind standard `xml` namespace to anything
public void testXmlNs() throws Exception
{
String xml = MAPPER.writeValueAsString(new Issue395());
// System.err.println("XML: "+xml);
assertEquals("<Issue395 xml:lang=\"en-US\"/>", xml.trim());
}
}

0 comments on commit b3926a2

Please sign in to comment.