File tree Expand file tree Collapse file tree 12 files changed +64
-20
lines changed
main/java/tools/jackson/dataformat/xml
test/java/tools/jackson/dataformat/xml Expand file tree Collapse file tree 12 files changed +64
-20
lines changed Original file line number Diff line number Diff line change 21
21
steps :
22
22
- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
23
23
- name : Set up JDK
24
- uses : actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
24
+ uses : actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
25
25
with :
26
26
distribution : ' temurin'
27
27
java-version : ${{ matrix.java_version }}
Original file line number Diff line number Diff line change 21
21
with :
22
22
ref : 3.x
23
23
- name : Set up JDK
24
- uses : actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
24
+ uses : actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
25
25
with :
26
26
distribution : ' temurin'
27
27
java-version : ${{ matrix.java_version }}
Original file line number Diff line number Diff line change 30
30
steps :
31
31
- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
32
32
- name : Set up JDK
33
- uses : actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
33
+ uses : actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
34
34
with :
35
35
distribution : ' temurin'
36
36
java-version : ${{ matrix.java_version }}
58
58
run : ./mvnw -B -q -ff -ntp test
59
59
- name : Publish code coverage
60
60
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
62
62
with :
63
63
token : ${{ secrets.CODECOV_TOKEN }}
64
64
files : ./target/site/jacoco/jacoco.xml
Original file line number Diff line number Diff line change @@ -271,3 +271,8 @@ Bas Passon (@bpasson)
271
271
* Reported, contributed fix for #646 : Deserializing fails when using builder classes
272
272
with `Iterable` Collection setters
273
273
(2.17.1 )
274
+
275
+ 多多冰冰 (@duoduobingbing)
276
+
277
+ * Contributed #745 : Add feature to include `standalone=' yes' ` in xml declaration
278
+ (2.19.0 )
Original file line number Diff line number Diff line change @@ -4,7 +4,10 @@ Project: jackson-dataformat-xml
4
4
=== Releases ===
5
5
------------------------------------------------------------------------
6
6
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 )
8
11
9
12
#700 : Unify testing structure/tools [JSTEP-10 ]
10
13
(fix contributed by Joo Hyuk K)
Original file line number Diff line number Diff line change @@ -28,6 +28,13 @@ public enum XmlWriteFeature implements FormatFeature
28
28
*/
29
29
WRITE_XML_1_1 (false ),
30
30
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
+
31
38
/**
32
39
* Feature that controls whether serialization of Java {@code null} values adds
33
40
* XML attribute of `xsi:nil`, as defined by XML Schema (see
Original file line number Diff line number Diff line change 19
19
import tools .jackson .core .io .NumberInput ;
20
20
import tools .jackson .core .util .ByteArrayBuilder ;
21
21
import tools .jackson .core .util .JacksonFeatureSet ;
22
- import tools .jackson .dataformat .xml .XmlWriteFeature ;
23
22
import tools .jackson .dataformat .xml .util .CaseInsensitiveNameSet ;
24
23
import tools .jackson .dataformat .xml .util .StaxUtil ;
25
24
Original file line number Diff line number Diff line change @@ -173,15 +173,23 @@ public void initGenerator() throws JacksonException
173
173
_initialized = true ;
174
174
try {
175
175
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
+ }
181
188
xmlDeclWritten = true ;
182
189
} else {
183
190
xmlDeclWritten = false ;
184
191
}
192
+
185
193
// as per [dataformat-xml#172], try adding indentation
186
194
if (xmlDeclWritten && (_xmlPrettyPrinter != null )) {
187
195
// ... but only if it is likely to succeed:
Original file line number Diff line number Diff line change 8
8
9
9
import com .ctc .wstx .stax .WstxInputFactory ;
10
10
import com .ctc .wstx .stax .WstxOutputFactory ;
11
+ import com .fasterxml .jackson .annotation .JsonRootName ;
11
12
12
13
import tools .jackson .databind .*;
13
14
import tools .jackson .dataformat .xml .*;
14
15
import tools .jackson .dataformat .xml .annotation .JacksonXmlProperty ;
15
- import tools .jackson .dataformat .xml .annotation .JacksonXmlRootElement ;
16
16
17
17
import static org .junit .jupiter .api .Assertions .assertNotNull ;
18
18
19
19
// for [dataformat-xml#326]
20
20
public class FailingNamespace326Test extends XmlTestUtil
21
21
{
22
- @ JacksonXmlRootElement ( localName = "new" )
22
+ @ JsonRootName ( "new" )
23
23
static class Bean {
24
24
@ JacksonXmlProperty (isAttribute = true )
25
25
public String source ="ECOM" ;
Original file line number Diff line number Diff line change 8
8
import tools .jackson .dataformat .xml .XmlMapper ;
9
9
import tools .jackson .dataformat .xml .XmlTestUtil ;
10
10
import tools .jackson .dataformat .xml .annotation .JacksonXmlProperty ;
11
- import tools .jackson .dataformat .xml .annotation .JacksonXmlRootElement ;
12
11
13
12
import static org .junit .jupiter .api .Assertions .assertEquals ;
14
13
import static org .junit .jupiter .api .Assertions .fail ;
@@ -17,7 +16,7 @@ public class TestNamespaces extends XmlTestUtil
17
16
{
18
17
final static String CHILD_NS = "uri:child" ;
19
18
20
- @ JacksonXmlRootElement ( localName ="person" , namespace ="http://example.org/person" )
19
+ @ JsonRootName ( value ="person" , namespace ="http://example.org/person" )
21
20
static class Person
22
21
{
23
22
private String name ;
@@ -63,9 +62,9 @@ static class ChildWithNsJsonProp {
63
62
}
64
63
65
64
/*
66
- /**********************************************************
67
- /* Unit tests
68
- /**********************************************************
65
+ /**********************************************************************
66
+ /* Test methods
67
+ /**********************************************************************
69
68
*/
70
69
71
70
private final XmlMapper MAPPER = newMapper ();
You can’t perform that action at this time.
0 commit comments