Skip to content

Commit b3926a2

Browse files
committed
Fix #395
1 parent 225d670 commit b3926a2

File tree

4 files changed

+30
-8
lines changed

4 files changed

+30
-8
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Some data-binding types overridden as well (ObjectMapper sub-classed as XmlMappe
6868
<dependency>
6969
<groupId>org.codehaus.woodstox</groupId>
7070
<artifactId>stax2-api</artifactId>
71-
<version>4.2</version>
71+
<version>4.2.1</version>
7272
<exclusions>
7373
<exclusion>
7474
<groupId>javax.xml.stream</groupId>
@@ -87,7 +87,7 @@ Some data-binding types overridden as well (ObjectMapper sub-classed as XmlMappe
8787
<dependency>
8888
<groupId>com.fasterxml.woodstox</groupId>
8989
<artifactId>woodstox-core</artifactId>
90-
<version>6.2.0</version>
90+
<version>6.2.1</version>
9191
<exclusions>
9292
<exclusion>
9393
<groupId>javax.xml.stream</groupId>

release-notes/CREDITS-2.x

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,8 @@ Luke Korth ([email protected])
6060

6161
* Reported #366: XML containing xsi:nil is improperly parsed
6262
(2.10.2)
63+
64+
Martin Vysny (mvysny@github)
65+
66+
* Reported #395: Namespace repairing generates xmlns definitions for xml: prefix (which is implicit)
67+
(2.10.5)

release-notes/VERSION-2.x

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ Project: jackson-dataformat-xml
66

77
2.10.5 (not yet released)
88

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

1113
2.10.4 (03-May-2020)
1214

src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestNamespaces.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,41 @@ public void setName(String name) {
1818
this.name = name;
1919
}
2020
}
21-
21+
22+
static class Issue395 {
23+
@JacksonXmlProperty(isAttribute = true, namespace = "http://www.w3.org/XML/1998/namespace",
24+
localName = "lang")
25+
public String lang = "en-US";
26+
}
27+
2228
/*
2329
/**********************************************************
2430
/* Unit tests
2531
/**********************************************************
2632
*/
27-
28-
// [Issue-26]: should prefer the "default namespace"
33+
34+
private final XmlMapper MAPPER = newMapper();
35+
36+
// [dataformat-xml#26]: should prefer the "default namespace"
2937
public void testRootNamespace() throws Exception
3038
{
3139
Person person = new Person();
3240
person.setName( "hello" );
3341

34-
XmlMapper xmlMapper = new XmlMapper();
35-
String xml = xmlMapper.writeValueAsString(person);
42+
String xml = MAPPER.writeValueAsString(person);
3643

3744
// should use "the default namespace"...
3845
final String PREFIX = "<person xmlns=";
3946
if (!xml.startsWith(PREFIX)) {
4047
fail("Expected XML to begin with '"+PREFIX+"', instead got: "+xml);
4148
}
4249
}
50+
51+
// [dataformat-xml#395]: should not bind standard `xml` namespace to anything
52+
public void testXmlNs() throws Exception
53+
{
54+
String xml = MAPPER.writeValueAsString(new Issue395());
55+
// System.err.println("XML: "+xml);
56+
assertEquals("<Issue395 xml:lang=\"en-US\"/>", xml.trim());
57+
}
4358
}

0 commit comments

Comments
 (0)