Skip to content

Fix Saxon-HE 12 trailing newline issue in XML serialization #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 9, 2025

Conversation

basmussen
Copy link
Contributor

Description

This PR fixes the trailing newline issue that occurs when upgrading Saxon-HE from 9.6.0-7 to 12.7.

Problem

Saxon 12 adds a trailing newline character to XML output when indenting is enabled, which wasn't present in Saxon 9.6. This breaks existing tests and changes the output format unexpectedly.

Solution

Modified DomUtils.asXml() to trim the trailing newline when indenting is enabled. This maintains backward compatibility and ensures consistent output across all Saxon versions.

Changes

  • Updated DomUtils.asXml(Node, boolean, Map<String,String>) to remove trailing newline when indent is true
  • Added comment explaining the Saxon version compatibility issue

Testing

  • Tested with Java 8, 11, 17, and 21
  • All existing tests pass
  • Verified that XML output format remains consistent

Fixes #22

dependabot bot and others added 2 commits June 9, 2025 16:29
Bumps net.sf.saxon:Saxon-HE from 9.6.0-7 to 12.7.

---
updated-dependencies:
- dependency-name: net.sf.saxon:Saxon-HE
  dependency-version: '12.7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
When Saxon-HE is upgraded to version 12.x, it adds a trailing newline
to XML output when indenting is enabled. This breaks backward
compatibility with tests expecting the output format from Saxon 9.6.

The fix trims the trailing newline in DomUtils.asXml() when indenting
is enabled, maintaining consistent output across Saxon versions.

Fixes #22
@basmussen basmussen merged commit aff6465 into develop Jun 9, 2025
5 checks passed
@basmussen basmussen deleted the test-saxon-pr branch June 9, 2025 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Saxon-HE 12 adds trailing newline when indenting XML output
1 participant