Skip to content

Commit 718b721

Browse files
authored
Merge branch '3.x' into tatu-claude/3.2/559-fix-xml-text-vs-creator
2 parents aa1c5dd + 1e41752 commit 718b721

29 files changed

Lines changed: 1520 additions & 191 deletions

.github/workflows/coverage-comment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
1414
steps:
1515
- name: Download comment artifact
16-
uses: dawidd6/action-download-artifact@8a338493df3d275e4a7a63bcff3b8fe97e51a927 # v19
16+
uses: dawidd6/action-download-artifact@8305c0f1062bb0d184d09ef4493ecb9288447732 # v20
1717
with:
1818
name: pr-comment
1919
path: pr-comment/

.github/workflows/main.yml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,40 +56,32 @@ jobs:
5656
run: ./mvnw -B -q -ff -ntp test jacoco:report
5757
- name: Publish code coverage
5858
if: ${{ matrix.release_build && github.event_name != 'pull_request' }}
59-
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3
59+
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
6060
with:
6161
token: ${{ secrets.CODECOV_TOKEN }}
6262
files: ./target/site/jacoco/jacoco.xml
6363
flags: unittests
6464
- name: Upload coverage report as artifact
6565
if: ${{ matrix.release_build && github.event_name != 'pull_request' }}
66-
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
66+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
6767
with:
6868
name: jacoco-report
6969
path: target/site/jacoco/jacoco.csv
7070
retention-days: 30
7171
- name: Download base branch coverage
7272
if: ${{ matrix.release_build && github.event_name == 'pull_request' }}
73-
uses: dawidd6/action-download-artifact@8a338493df3d275e4a7a63bcff3b8fe97e51a927 # v19
73+
uses: dawidd6/action-download-artifact@8305c0f1062bb0d184d09ef4493ecb9288447732 # v20
7474
continue-on-error: true
7575
with:
7676
workflow: main.yml
7777
branch: ${{ github.event.pull_request.base.ref }}
7878
name: jacoco-report
7979
path: base-coverage/
80-
- name: Generate coverage summary
81-
if: ${{ matrix.release_build && github.event_name == 'pull_request' }}
82-
id: jacoco
83-
uses: cicirello/jacoco-badge-generator@72266185b7ee48a6fd74eaf0238395cc8b14fef8 # v2.12.1
84-
with:
85-
jacoco-csv-file: target/site/jacoco/jacoco.csv
86-
generate-coverage-badge: false
87-
generate-branches-badge: false
88-
generate-summary: true
8980
- name: Generate coverage comment
9081
if: ${{ matrix.release_build && github.event_name == 'pull_request' }}
9182
run: |
92-
# Helper functions
83+
# Parse JaCoCo CSV to compute coverage percentage
84+
# Columns: GROUP,PACKAGE,CLASS,INSTRUCTION_MISSED(4),INSTRUCTION_COVERED(5),BRANCH_MISSED(6),BRANCH_COVERED(7),...
9385
parse_coverage() {
9486
local csv_file=$1 col_missed=$2 col_covered=$3
9587
awk -F',' -v m="$col_missed" -v c="$col_covered" \
@@ -121,9 +113,9 @@ jobs:
121113
}'
122114
}
123115
124-
# Convert decimal to percentage and round to 1 decimal place
125-
COVERAGE=$(awk -v cov="${{ steps.jacoco.outputs.coverage }}" 'BEGIN { printf "%.2f", cov * 100 }')
126-
BRANCHES=$(awk -v br="${{ steps.jacoco.outputs.branches }}" 'BEGIN { printf "%.2f", br * 100 }')
116+
# Compute current coverage from JaCoCo CSV
117+
COVERAGE=$(parse_coverage "target/site/jacoco/jacoco.csv" 4 5)
118+
BRANCHES=$(parse_coverage "target/site/jacoco/jacoco.csv" 6 7)
127119
128120
# Check if base coverage artifact was downloaded and calculate deltas
129121
HAS_DELTA=false
@@ -174,7 +166,7 @@ jobs:
174166
echo "$COMMENT_BODY" > pr-comment/comment-body.txt
175167
- name: Upload PR comment
176168
if: ${{ matrix.release_build && github.event_name == 'pull_request' }}
177-
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
169+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
178170
with:
179171
name: pr-comment
180172
path: pr-comment/

README.md

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ Specifically:
2424
| Type | Status |
2525
| ---- | ------ |
2626
| Build (CI) | [![Build (github)](https://github.com/FasterXML/jackson-dataformat-xml/actions/workflows/main.yml/badge.svg)](https://github.com/FasterXML/jackson-dataformat-xml/actions/workflows/main.yml) |
27-
| Artifact | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.fasterxml.jackson.dataformat/jackson-dataformat-xml/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.fasterxml.jackson.dataformat/jackson-dataformat-xml) |
27+
| Artifact | [![Maven Central](https://img.shields.io/maven-central/v/tools.jackson.dataformat/jackson-dataformat-xml.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/tools.jackson.dataformat/jackson-dataformat-xml) |
2828
| OSS Sponsorship | [![Tidelift](https://tidelift.com/badges/package/maven/com.fasterxml.jackson.dataformat:jackson-dataformat-xml)](https://tidelift.com/subscription/pkg/maven-com-fasterxml-jackson-dataformat-jackson-dataformat-xml?utm_source=maven-com-fasterxml-jackson-dataformat-jackson-dataformat-xml&utm_medium=referral&utm_campaign=readme) |
29-
| Javadocs | [![Javadoc](https://javadoc.io/badge/com.fasterxml.jackson.dataformat/jackson-dataformat-xml.svg)](http://www.javadoc.io/doc/com.fasterxml.jackson.dataformat/jackson-dataformat-xml) |
29+
| Javadocs | [![Javadoc](https://javadoc.io/badge/tools.jackson.dataformat/jackson-dataformat-xml.svg)](http://www.javadoc.io/doc/tools.jackson.dataformat/jackson-dataformat-xml) |
3030
| Code coverage (2.19) | [![codecov.io](https://codecov.io/github/FasterXML/jackson-dataformat-xml/coverage.svg?branch=2.19)](https://codecov.io/github/FasterXML/jackson-dataformat-xml?branch=2.19) |
3131
| OpenSSF Score | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/FasterXML/jackson-dataformat-xml/badge)](https://securityscorecards.dev/viewer/?uri=github.com/FasterXML/jackson-dataformat-xml) |
3232
| Fuzzing | [![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/jackson-dataformat-xml.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:jackson-dataformat-xml) |
3333

3434
## Branches
3535

36-
`master` branch is for developing the next major Jackson version -- 3.0 -- but there
37-
are active maintenance branches in which much of development happens:
36+
`3.x` branch is for developing the next major Jackson version -- 3.2 -- but there
37+
are active maintenance branches for LTS releases:
3838

39-
* `2.19` is for developing the next minor 2.x version
40-
* `2.18` is for backported fixes to include in 2.18.x patch versions
41-
* `2.17` is for backported fixes to include in 2.17.x patch versions
39+
* `3.1`
40+
* `2.21`
41+
* `2.18`
4242

4343
Older branches are usually not changed but are available for historic reasons.
4444
All released versions have matching git tags (`jackson-dataformat-xml-2.17.1`).
@@ -49,21 +49,39 @@ All modules are licensed under [Apache License 2.0](http://www.apache.org/licens
4949

5050
## Maven dependency
5151

52+
To use Jackson 3.x compatible version of this extension on Maven-based projects, use following dependency:
53+
54+
Maven:
55+
```xml
56+
<dependency>
57+
<groupId>tools.jackson.dataformat</groupId>
58+
<artifactId>jackson-dataformat-xml</artifactId>
59+
<version>3.1.1</version>
60+
</dependency>
61+
```
62+
63+
Gradle:
64+
```groovy
65+
dependencies {
66+
implementation 'tools.jackson.dataformat:jackson-dataformat-xml:3.1.1'
67+
}
68+
```
69+
5270
To use Jackson 2.x compatible version of this extension on Maven-based projects, use following dependency:
5371

5472
Maven:
5573
```xml
5674
<dependency>
5775
<groupId>com.fasterxml.jackson.dataformat</groupId>
5876
<artifactId>jackson-dataformat-xml</artifactId>
59-
<version>2.18.1</version>
77+
<version>2.21.2</version>
6078
</dependency>
6179
```
6280

6381
Gradle:
6482
```groovy
6583
dependencies {
66-
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.18.1'
84+
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.21.2'
6785
}
6886
```
6987

release-notes/CREDITS

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ Christopher McVay (@mcvayc)
3939
* Fixed #306: Can not use `@JacksonXmlText` for Creator property (creator parameter)
4040
(3.2.0)
4141

42+
Stefan Walter (@marvin9000)
43+
* Requested #150: Allow specifying DOCTYPE declaration (`<!DOCTYPE root ...>`) to write
44+
(3.2.0)
45+
46+
Leonard Meyer (@LeonardMeyer)
47+
* Reported #247: `@JacksonXmlRootElement` does not enforce the local name during
48+
deserialization (add `XmlReadFeature.ENFORCE_ROOT_ELEMENT_NAME`)
49+
(3.2.0)
50+
4251
Tobias M (@lightbringer)
4352
* Reported #248: `@JacksonXmlProperty` with attributes raises an exception
4453
when used with `@JsonIdentityInfo`
@@ -47,16 +56,29 @@ Tobias M (@lightbringer)
4756
Eduard Wirch (@ewirch)
4857
* Reported #306: Can not use `@JacksonXmlText` for Creator property (creator parameter)
4958
(3.2.0)
59+
* Requested #358: Allow skipping attributes from the `http://www.w3.org/2001/XMLSchema-instance`
60+
namespace (with new `XmlReadFeature.SKIP_UNKNOWN_XSI_ATTRIBUTES`)
61+
(3.2.0)
5062

5163
Ruven Chu (@Chubacca)
5264
* Reported #334: `@JacksonXmlElementWrapper(useWrapping=false)` fails when using
5365
a `DeserializerModifier` that delegates
54-
66+
(3.2.0)
67+
68+
Florian Krauthan (@fkrauthan)
69+
* Reported #448: Allow use of `@JsonRawValue` without wrapping element
70+
(3.2.0)
71+
5572
Lon Varscsak (@lonvarscsak)
5673
* Reported #449: Trouble dealing with JacksonXMLText if properties are present or
5774
if element is in a collection
5875
(3.2.0)
5976

77+
Ondrej Zizka (@OndraZizka)
78+
* Requested #452: Allow adding `<?xml-stylesheet ...>` declarations (Processing
79+
Instructions)
80+
(3.2.0)
81+
6082
Jiri Mikulasek (@jimirocks)
6183
* Reported #455: Can't deserialize list in JsonSubtype when type property is visible
6284
(3.2.0)

release-notes/VERSION

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@ Version: 3.x (for earlier see VERSION-2.x)
1515
#149: `@JacksonXmlElementWrapper` as a `@JsonCreator parameter` not working
1616
(reported by Dai M)
1717
(fix by Christopher M))
18+
#150: Allow specifying DOCTYPE declaration (`<!DOCTYPE root ...>`) to write
19+
(requested by Stefan W)
20+
(fix by @cowtowncoder)
1821
#192: Two wrapped lists with items of same name conflict
1922
(reported by @TeemuStenhammar)
2023
(fix by @cowtowncoder, w/ Claude code)
24+
#247: `@JacksonXmlRootElement` does not enforce the local name during
25+
deserialization (add `XmlReadFeature.ENFORCE_ROOT_ELEMENT_NAME`)
26+
(reported by Leonard M)
27+
(fix by @cowtowncoder, w/ Claude code)
2128
#248: `@JacksonXmlProperty` with attributes raises an exception when used
2229
with `@JsonIdentityInfo`
2330
(reported by Tobias M)
@@ -33,14 +40,24 @@ Version: 3.x (for earlier see VERSION-2.x)
3340
a `DeserializerModifier` that delegates
3441
(reported by Ruven C)
3542
(fix by @cowtowncoder, w/ Claude code)
43+
#358: Allow skipping attributes from the `http://www.w3.org/2001/XMLSchema-instance`
44+
namespace (with new `XmlReadFeature.SKIP_UNKNOWN_XSI_ATTRIBUTES`)
45+
(requested by Eduard W)
46+
(fix by @cowtowncoder, w/ Claude code)
3647
#426: `InvalidTypeIdException` when parsing XML to POJO containing nested `List<>`,
3748
custom `TypeIdResolver`
3849
(reported by @ankagar)
3950
(fix by @cowtowncoder, w/ Claude code)
51+
#448: Allow use of `@JsonRawValue` without wrapping element
52+
(reported by Florian K)
4053
#449: Trouble dealing with JacksonXMLText if properties are present or
4154
if element is in a collection
4255
(reported by Lon V)
4356
(fix by @cowtowncoder, w/ Claude code)
57+
#452: Allow adding `<?xml-stylesheet ...>` declarations (Processing
58+
Instructions)
59+
(requested by Ondrej Z)
60+
(fix by @cowtowncoder)
4461
#455: Can't deserialize list in JsonSubtype when type property is visible
4562
(reported by Jiri M)
4663
(fix by @cowtowncoder, w/ Claude code)
@@ -104,6 +121,19 @@ Version: 3.x (for earlier see VERSION-2.x)
104121
#802: Serialization with Polymorphisme and `EXTERNAL_PROPERTY` = duplicate property
105122
(reported by @ Adrien-dev25 )
106123
(fix by @cowtowncoder, w/ Claude code)
124+
#845: Implement `JsonGenerator` methods `writeComment()` and `canWriteComments()`
125+
(implemented by @cowtowncoder, w/ Claude code)
126+
#849: Allow writing Comments in Document Prolog (before root element)
127+
(implemented by @cowtowncoder)
128+
#853: `InvalidDefinitionException` on classes using
129+
`@JacksonXmlElementWrapper` and `@JacksonXmlProperty`
130+
(reported by @soc)
131+
(fix by @cowtowncoder, w/ Claude code)
132+
133+
3.1.2 (11-Apr-2026)
134+
3.1.1 (27-Mar-2026)
135+
136+
No changes since 3.1.0
107137

108138
3.1.0 (23-Feb-2026)
109139

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ public boolean isEnabled(XmlWriteFeature f) {
475475
return _serializationConfig.hasFormatFeature(f);
476476
}
477477

478-
479478
/*
480479
/**********************************************************************
481480
/* XML-specific access
@@ -497,7 +496,8 @@ public FromXmlParser createParser(XMLStreamReader r) throws IOException {
497496
*/
498497
public ToXmlGenerator createGenerator(XMLStreamWriter w) throws IOException {
499498
SerializationContextExt prov = _serializationContext(serializationConfig());
500-
return tokenStreamFactory().createGenerator(prov, w);
499+
return (ToXmlGenerator) _initializeGenerator(
500+
tokenStreamFactory().createGenerator(prov, w));
501501
}
502502

503503
/**

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,24 @@ public enum XmlReadFeature implements FormatFeature
4242
*/
4343
EMPTY_ELEMENT_AS_NULL(false),
4444

45+
/**
46+
* Feature that controls whether the name of the root XML element is
47+
* verified against the expected root name during deserialization. The expected
48+
* root name is determined from {@code @JsonRootName}, {@code @JacksonXmlRootElement},
49+
* or the simple class name of the target type (in that priority order).
50+
*<p>
51+
* When enabled, a mismatch between the actual root element name and the expected
52+
* name will result in a {@link tools.jackson.databind.exc.MismatchedInputException}.
53+
* When disabled (the default), any root element name is accepted.
54+
* Note that Fully-Qualified Names (FQN) comparison is used: that is, both local name
55+
* and namespace URI must match.
56+
*<p>
57+
* Default setting is {@code false} for backwards-compatibility.
58+
*
59+
* @since 3.2
60+
*/
61+
ENFORCE_ROOT_ELEMENT_NAME(false),
62+
4563
/**
4664
* Feature that indicates whether XML Schema Instance attribute
4765
* {@code xsi:nil} will be processed automatically -- to indicate {@code null}
@@ -55,6 +73,24 @@ public enum XmlReadFeature implements FormatFeature
5573
*/
5674
PROCESS_XSI_NIL(true),
5775

76+
/**
77+
* Feature that controls whether XML Schema Instance (XSI) namespace attributes
78+
* other than {@code xsi:nil} and {@code xsi:type} (which have their own handling
79+
* via {@link #PROCESS_XSI_NIL} and {@link #AUTO_DETECT_XSI_TYPE}) are silently
80+
* skipped during deserialization. Attributes affected include {@code xsi:schemaLocation}
81+
* and {@code xsi:noNamespaceSchemaLocation}.
82+
*<p>
83+
* When enabled, these attributes are ignored and will not cause
84+
* {@code UnrecognizedPropertyException}. When disabled (default), they are
85+
* exposed as regular attributes and may require matching POJO properties
86+
* or {@code DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES} to be disabled.
87+
*<p>
88+
* Default setting is {@code false}.
89+
*
90+
* @since 3.2
91+
*/
92+
SKIP_UNKNOWN_XSI_ATTRIBUTES(false),
93+
5894
;
5995

6096
private final boolean _defaultState;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@
2727
*/
2828
public class XmlTypeResolverBuilder extends StdTypeResolverBuilder
2929
{
30-
public XmlTypeResolverBuilder(JsonTypeInfo.Value typeInfo)
30+
public XmlTypeResolverBuilder(JsonTypeInfo.Value typeInfo,
31+
JavaType detectedBaseType)
3132
{
32-
super(typeInfo);
33+
super(typeInfo, detectedBaseType);
3334
}
3435

3536
@Override

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ public class XmlTypeResolverProvider
1414
{
1515
private static final long serialVersionUID = 3L;
1616

17-
@Override
17+
@Override // @since 3.2
1818
protected TypeResolverBuilder<?> _constructStdTypeResolverBuilder(MapperConfig<?> config,
19-
JsonTypeInfo.Value typeInfo, JavaType baseType) {
20-
return new XmlTypeResolverBuilder(typeInfo);
19+
JsonTypeInfo.Value typeInfo, JavaType baseType,
20+
JavaType detectedBaseType) {
21+
return new XmlTypeResolverBuilder(typeInfo, detectedBaseType);
2122
}
2223
}

0 commit comments

Comments
 (0)