Skip to content

Update xml writer#627

Open
Claudenw wants to merge 13 commits intomasterfrom
update-XMLWriter
Open

Update xml writer#627
Claudenw wants to merge 13 commits intomasterfrom
update-XMLWriter

Conversation

@Claudenw
Copy link
Contributor

@Claudenw Claudenw commented Mar 8, 2026

Update the XmlWriter to write to any appendable.
Move the XMLChar class to its own file and use the implementation for Xerces-j to pick up fixes.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 9, 2026

@Claudenw Claudenw self-assigned this Mar 9, 2026
Copy link
Contributor

@ottlinger ottlinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM - all sonarcloud warnings seem reasonable and should be applied before merging.

Besides I was just wonderung if more tests are needed to cover more of the corner cases that XmlWriter handles.

Thanks for all your work!

writer.write("<!-- ");
content(text);
writer.write(" -->");
maybeCloseElement();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you reformat this section or is it a UI problem in the web UI? (lines seem to have different indentation)

@Override
public void close() throws IOException {
closeDocument();
if (appendable instanceof Closeable) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        if (appendable instanceof Closeable) {

Sonarcloud's suggestion seems reasonable to me .... would you mind changing?

import static org.junit.jupiter.api.Assertions.assertTrue;


public class XmlWriterTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While scanning the changes in the writer package I wondered if there's enough code coverage for the special cases handled in XmlWriter or if more tests could be added (I only look at the code from the GitHub UI and not in an IDE).

<name>Apache Creadur RAT::Core</name>
<description>The core functionality of RAT that is used by all clients.</description>
<properties>
<sonar.exclusions>src/main/java/org/apache/rat/report/xml/writer/XMLChar.java</sonar.exclusions>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to add a comment here such as
"Code ist copied over from Xerces directly plus a reference to a RAT-xyz?"

Thanks, just for future people to give more context.

transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
Transformer transformer = StandardXmlFactory.create(styleIn);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing this duplicate code warning by putting it in a new class.

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.

2 participants