From b3926a23ef466aecaa62849f7b4a0a753fc9fdb4 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Wed, 13 May 2020 21:34:32 -0700 Subject: [PATCH] Fix #395 --- pom.xml | 4 +-- release-notes/CREDITS-2.x | 5 ++++ release-notes/VERSION-2.x | 4 ++- .../dataformat/xml/ser/TestNamespaces.java | 25 +++++++++++++++---- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 5076d8ee2..05f2ba071 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,7 @@ Some data-binding types overridden as well (ObjectMapper sub-classed as XmlMappe org.codehaus.woodstox stax2-api - 4.2 + 4.2.1 javax.xml.stream @@ -87,7 +87,7 @@ Some data-binding types overridden as well (ObjectMapper sub-classed as XmlMappe com.fasterxml.woodstox woodstox-core - 6.2.0 + 6.2.1 javax.xml.stream diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x index cd7b5d71d..14000f4d2 100644 --- a/release-notes/CREDITS-2.x +++ b/release-notes/CREDITS-2.x @@ -60,3 +60,8 @@ Luke Korth (lkorth@github.com) * 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) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 1a31d5dc5..13fd6e29c 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -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) diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestNamespaces.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestNamespaces.java index 356d19def..1fbaebd56 100644 --- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestNamespaces.java +++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestNamespaces.java @@ -18,21 +18,28 @@ 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 = "", xml.trim()); + } }