diff --git a/release-notes/VERSION b/release-notes/VERSION index 6060acbb1..cbd31291c 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -14,5 +14,8 @@ Version: 3.x (for earlier see VERSION-2.x) `ToXmlGenerator.Feature` as `XmlWriteFeature` #701: Change 3.0 to use `module-info.java` directly, remove use of Moditect #725: Change `XmlWriteFeature.UNWRAP_ROOT_OBJECT_NODE` default to `true` +#727: Change `XmlWriteFeature.WRITE_NULLS_AS_XSI_NIL` default to `true` +#728: Change `XmlWriteFeature.AUTO_DETECT_XSI_TYPE` default to `true` +#729: Change `XmlWriteFeature.WRITE_XML_SCHEMA_CONFORMING_FLOATS` default to `true` - Add `XmlMapper.shared()` - Minimum Java baseline: Java 17 diff --git a/src/main/java/tools/jackson/dataformat/xml/XmlWriteFeature.java b/src/main/java/tools/jackson/dataformat/xml/XmlWriteFeature.java index 99431b4ee..8e42e2cc4 100644 --- a/src/main/java/tools/jackson/dataformat/xml/XmlWriteFeature.java +++ b/src/main/java/tools/jackson/dataformat/xml/XmlWriteFeature.java @@ -36,9 +36,10 @@ public enum XmlWriteFeature implements FormatFeature * If enabled, `xsi:nil` attribute will be added to the empty element; if disabled, * it will not. *
- * Feature is disabled by default for backwards compatibility. + * Default setting is {@code true} (enabled) in Jackson 3.x: + * it was {@code false} (disabled)in Jackson 2.x. */ - WRITE_NULLS_AS_XSI_NIL(false), + WRITE_NULLS_AS_XSI_NIL(true), /** * Feature that determines writing of root values of type {@code ObjectNode} @@ -51,8 +52,8 @@ public enum XmlWriteFeature implements FormatFeature * root element name is determined using normal logic (either explicitly * configured, or {@code ObjectNode} otherwise). *
- * Default setting is {@code true} (enabled) in Jackson 3.0: - * it was {@code false} in Jackson 2.x. + * Default setting is {@code true} (enabled) in Jackson 3.x: + * it was {@code false} (disabled)in Jackson 2.x. */ UNWRAP_ROOT_OBJECT_NODE(true), @@ -64,8 +65,11 @@ public enum XmlWriteFeature implements FormatFeature * and output is indicated to be done as XML Attribute. * This is mostly desirable for Polymorphic handling where it is difficult * to specify XML Namespace for type identifier + *
+ * Default setting is {@code true} (enabled) in Jackson 3.0: + * it was {@code false} (disabled)in Jackson 2.x. */ - AUTO_DETECT_XSI_TYPE(false), + AUTO_DETECT_XSI_TYPE(true), /** * Feature that determines how floating-point infinity values are @@ -92,9 +96,10 @@ public enum XmlWriteFeature implements FormatFeature * so there is no corresponding * {@link tools.jackson.dataformat.xml.XmlReadFeature}. *
- * Feature is disabled by default for backwards compatibility.
+ * Default setting is {@code true} (enabled) in Jackson 3.0:
+ * it was {@code false} (disabled)in Jackson 2.x.
*/
- WRITE_XML_SCHEMA_CONFORMING_FLOATS(false),
+ WRITE_XML_SCHEMA_CONFORMING_FLOATS(true),
;
private final boolean _defaultState;
diff --git a/src/main/java/tools/jackson/dataformat/xml/annotation/JacksonXmlRootElement.java b/src/main/java/tools/jackson/dataformat/xml/annotation/JacksonXmlRootElement.java
index fd3dbcc46..3d3612de1 100644
--- a/src/main/java/tools/jackson/dataformat/xml/annotation/JacksonXmlRootElement.java
+++ b/src/main/java/tools/jackson/dataformat/xml/annotation/JacksonXmlRootElement.java
@@ -21,9 +21,12 @@
* {@link com.fasterxml.jackson.annotation.JsonRootName} instead.
* About the only expected usage may be to have different root name for XML
* content than other formats.
+ *
+ * @deprecated Since 2.4 use {@link com.fasterxml.jackson.annotation.JsonRootName} instead
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
+@Deprecated
public @interface JacksonXmlRootElement
{
String namespace() default "";
diff --git a/src/test/java/tools/jackson/dataformat/xml/misc/RootNameTest.java b/src/test/java/tools/jackson/dataformat/xml/misc/RootNameTest.java
index 4ede0c222..044257f8e 100644
--- a/src/test/java/tools/jackson/dataformat/xml/misc/RootNameTest.java
+++ b/src/test/java/tools/jackson/dataformat/xml/misc/RootNameTest.java
@@ -1,6 +1,5 @@
package tools.jackson.dataformat.xml.misc;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -10,6 +9,7 @@
import tools.jackson.databind.PropertyName;
import tools.jackson.dataformat.xml.XmlTestUtil;
+import tools.jackson.dataformat.xml.XmlWriteFeature;
import tools.jackson.dataformat.xml.XmlMapper;
import tools.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
@@ -17,8 +17,9 @@
import static org.junit.jupiter.api.Assertions.fail;
// NOTE: even tho `@JacksonXmlRootElement` will be deprecated in near
-// future (possibly in 2.13) -- to be replaced by `@JsonRootName` -- this
+// future -- to be replaced by `@JsonRootName` -- this
// test will use it to ensure we handle both annotations as expected
+@SuppressWarnings({ "serial" })
public class RootNameTest extends XmlTestUtil
{
static class RootBeanBase
@@ -31,19 +32,21 @@ public RootBeanBase(String v) {
}
}
+ @SuppressWarnings("deprecation")
@JacksonXmlRootElement(localName="root")
static class RootBean extends RootBeanBase
{
protected RootBean() { super(); }
}
+ @SuppressWarnings("deprecation")
@JacksonXmlRootElement(localName="nsRoot", namespace="http://foo")
static class NsRootBean
{
public String value = "abc";
}
- @SuppressWarnings("serial")
+ @SuppressWarnings("deprecation")
@JacksonXmlRootElement(localName="TheStrings")
static class StringList extends ArrayList