Skip to content

Commit bb16595

Browse files
committed
Merge branch '2.19' into 3.x
2 parents 5aef71b + 361d2ff commit bb16595

File tree

12 files changed

+64
-20
lines changed

12 files changed

+64
-20
lines changed

.github/workflows/dep_build_v2.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2323
- name: Set up JDK
24-
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
24+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
2525
with:
2626
distribution: 'temurin'
2727
java-version: ${{ matrix.java_version }}

.github/workflows/dep_build_v3.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
with:
2222
ref: 3.x
2323
- name: Set up JDK
24-
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
24+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
2525
with:
2626
distribution: 'temurin'
2727
java-version: ${{ matrix.java_version }}

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
steps:
3131
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3232
- name: Set up JDK
33-
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
33+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
3434
with:
3535
distribution: 'temurin'
3636
java-version: ${{ matrix.java_version }}
@@ -58,7 +58,7 @@ jobs:
5858
run: ./mvnw -B -q -ff -ntp test
5959
- name: Publish code coverage
6060
if: ${{ matrix.release_build && github.event_name != 'pull_request' }}
61-
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5.4.0
61+
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
6262
with:
6363
token: ${{ secrets.CODECOV_TOKEN }}
6464
files: ./target/site/jacoco/jacoco.xml

release-notes/CREDITS-2.x

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,8 @@ Bas Passon (@bpasson)
271271
* Reported, contributed fix for #646: Deserializing fails when using builder classes
272272
with `Iterable` Collection setters
273273
(2.17.1)
274+
275+
多多冰冰 (@duoduobingbing)
276+
277+
* Contributed #745: Add feature to include `standalone='yes'` in xml declaration
278+
(2.19.0)

release-notes/VERSION-2.x

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ Project: jackson-dataformat-xml
44
=== Releases ===
55
------------------------------------------------------------------------
66

7-
2.19.0-rc (07-Apr-2025)
7+
#745: Add feature to include `standalone='yes'` in xml declaration
8+
(contributed by @duoduobingbing)
9+
10+
2.19.0-rc2 (07-Apr-2025)
811

912
#700: Unify testing structure/tools [JSTEP-10]
1013
(fix contributed by Joo Hyuk K)

src/main/java/tools/jackson/dataformat/xml/XmlWriteFeature.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ public enum XmlWriteFeature implements FormatFeature
2828
*/
2929
WRITE_XML_1_1(false),
3030

31+
/**
32+
* Feature that controls whether XML declaration should include the standalone attribute
33+
* when generator is initialized (true) or not (false). Only honored when
34+
* {@link #WRITE_XML_DECLARATION WRITE_XML_DECLARATION} is enabled
35+
*/
36+
WRITE_STANDALONE_YES_TO_XML_DECLARATION(false),
37+
3138
/**
3239
* Feature that controls whether serialization of Java {@code null} values adds
3340
* XML attribute of `xsi:nil`, as defined by XML Schema (see

src/main/java/tools/jackson/dataformat/xml/deser/FromXmlParser.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import tools.jackson.core.io.NumberInput;
2020
import tools.jackson.core.util.ByteArrayBuilder;
2121
import tools.jackson.core.util.JacksonFeatureSet;
22-
import tools.jackson.dataformat.xml.XmlWriteFeature;
2322
import tools.jackson.dataformat.xml.util.CaseInsensitiveNameSet;
2423
import tools.jackson.dataformat.xml.util.StaxUtil;
2524

src/main/java/tools/jackson/dataformat/xml/ser/ToXmlGenerator.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,23 @@ public void initGenerator() throws JacksonException
173173
_initialized = true;
174174
try {
175175
boolean xmlDeclWritten;
176-
if (XmlWriteFeature.WRITE_XML_1_1.enabledIn(_formatFeatures)) {
177-
_xmlWriter.writeStartDocument("UTF-8", "1.1");
178-
xmlDeclWritten = true;
179-
} else if (XmlWriteFeature.WRITE_XML_DECLARATION.enabledIn(_formatFeatures)) {
180-
_xmlWriter.writeStartDocument("UTF-8", "1.0");
176+
177+
if (XmlWriteFeature.WRITE_XML_1_1.enabledIn(_formatFeatures)
178+
|| XmlWriteFeature.WRITE_XML_DECLARATION.enabledIn(_formatFeatures)) {
179+
180+
String xmlVersion = XmlWriteFeature.WRITE_XML_1_1.enabledIn(_formatFeatures) ? "1.1" : "1.0";
181+
String encoding = "UTF-8";
182+
183+
if (XmlWriteFeature.WRITE_STANDALONE_YES_TO_XML_DECLARATION.enabledIn(_formatFeatures)) {
184+
_xmlWriter.writeStartDocument(xmlVersion, encoding, true);
185+
} else {
186+
_xmlWriter.writeStartDocument(encoding, xmlVersion);
187+
}
181188
xmlDeclWritten = true;
182189
} else {
183190
xmlDeclWritten = false;
184191
}
192+
185193
// as per [dataformat-xml#172], try adding indentation
186194
if (xmlDeclWritten && (_xmlPrettyPrinter != null)) {
187195
// ... but only if it is likely to succeed:

src/test/java/tools/jackson/dataformat/xml/misc/FailingNamespace326Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88

99
import com.ctc.wstx.stax.WstxInputFactory;
1010
import com.ctc.wstx.stax.WstxOutputFactory;
11+
import com.fasterxml.jackson.annotation.JsonRootName;
1112

1213
import tools.jackson.databind.*;
1314
import tools.jackson.dataformat.xml.*;
1415
import tools.jackson.dataformat.xml.annotation.JacksonXmlProperty;
15-
import tools.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
1616

1717
import static org.junit.jupiter.api.Assertions.assertNotNull;
1818

1919
// for [dataformat-xml#326]
2020
public class FailingNamespace326Test extends XmlTestUtil
2121
{
22-
@JacksonXmlRootElement(localName = "new")
22+
@JsonRootName("new")
2323
static class Bean {
2424
@JacksonXmlProperty(isAttribute = true)
2525
public String source="ECOM";

src/test/java/tools/jackson/dataformat/xml/ser/TestNamespaces.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import tools.jackson.dataformat.xml.XmlMapper;
99
import tools.jackson.dataformat.xml.XmlTestUtil;
1010
import tools.jackson.dataformat.xml.annotation.JacksonXmlProperty;
11-
import tools.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
1211

1312
import static org.junit.jupiter.api.Assertions.assertEquals;
1413
import static org.junit.jupiter.api.Assertions.fail;
@@ -17,7 +16,7 @@ public class TestNamespaces extends XmlTestUtil
1716
{
1817
final static String CHILD_NS = "uri:child";
1918

20-
@JacksonXmlRootElement(localName="person", namespace="http://example.org/person" )
19+
@JsonRootName(value="person", namespace="http://example.org/person" )
2120
static class Person
2221
{
2322
private String name;
@@ -63,9 +62,9 @@ static class ChildWithNsJsonProp {
6362
}
6463

6564
/*
66-
/**********************************************************
67-
/* Unit tests
68-
/**********************************************************
65+
/**********************************************************************
66+
/* Test methods
67+
/**********************************************************************
6968
*/
7069

7170
private final XmlMapper MAPPER = newMapper();

0 commit comments

Comments
 (0)