FasterXML / FasterXML/aalto-xml

writeSpace() in StreamWriterBase does not close XML start tag.

Open Beginner friendly
#134 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
306
Forks
71
PR merge metrics
No merged PRs in 30d

Description

Both overloads of writeSpace() do not close starting tags that may be open before writing the whitespace. This means that when using writeStartElement() followed by writeSpace(\n), the starting tag will only be closed in the next line.

I'm not sure this is necessarily incorrect, but it is visually unappealing. The Javadoc for XMLStreamWriter2 interface states that "This method is useful for things like outputting indentation.", which is why I expected the starting tag to be closed before writing the whitespace. This is also how Woodstox's BaseStreamWriter behaves, as it simply delegates to writeRaw, which does close the start tag.

Is this intended behaviour? If yes, I can use writeRaw as a workaround. Otherwise I could prepare a pull request.

Actual result:
```

```
Expected result:
```

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with both writeSpace() overloads and the XMLStreamWriter2 Javadoc, then trace how writeStartElement() leaves the start tag open. Reproduce the actual and expected output shown in the issue, and verify that whitespace after an open start tag closes that tag before being written.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.