Skip to content

Enable command-line argument for pretty printing XML output (#268)#295

Open
ermahesh wants to merge 2 commits intousnistgov:developfrom
ermahesh:enhancement/pretty-print-transformer
Open

Enable command-line argument for pretty printing XML output (#268)#295
ermahesh wants to merge 2 commits intousnistgov:developfrom
ermahesh:enhancement/pretty-print-transformer

Conversation

@ermahesh
Copy link

@ermahesh ermahesh commented Jun 18, 2025

Committer Notes

Fixes #268

This PR introduces a new command-line argument to enable pretty-printed XML output in the CLI tool.

Key Enhancements:

  • ✅ Added a --pretty-print CLI flag to toggle formatted XML output.
  • ✅ Integrated pretty-printing logic in the XML transformer flow.
  • ✅ Replaced FileOutputStream with Files.newOutputStream(...) for PMD compliance.
  • ✅ Added unit tests verifying formatted vs non-formatted output.
  • ✅ Verified behavior remains unchanged when the flag is not used.

Additional Notes:

  • This is my first contribution to this project. Kindly review and consider accepting this PR. I would be honored to be recognized as a contributor to OSCAL CLI.

Submission Checklist:

  • Correct base branch selected.
  • Maintainers allowed to edit the PR.
  • Verified no conflicting open PRs.
  • Squashed non-relevant commits.
  • All CI/CD checks passed.

Core Feature Checklist:

  • Explained what the change does and why.
  • Added relevant unit tests.
  • Updated help text or usage documentation.

@iMichaela
Copy link

@ermahesh - Thank you for your contributions. We will review the code and test the functionality.

Copy link

@selenaxiao-nist selenaxiao-nist left a comment

Choose a reason for hiding this comment

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

@ermahesh Please change PrettyPrinter class to use SaxonTransformerFactory. Refer to XMLOperations class

@ermahesh
Copy link
Author

@selenaxiao-nist @iMichaela : I see the build fails for a different reason , Should we fixing that as part of this PR ?

@iMichaela
Copy link

@ermahesh

  1. It appears that your pom.xml file is not the one we have in the develop branch, but rather the one from the main branch. XMLresolver version is defines in pom.xml
  2. Build and test actions will continue to fail due to Sonatype Maven changes. The team will test locally the proposed changes, and temporary remove all Maven pre-release tests.

@iMichaela
Copy link

@selenaxiao-nist @iMichaela : I see the build fails for a different reason , Should we fixing that as part of this PR ?

Ideally - yes. Due to more recent policy on open-source, we might, for now, just temporarily remove the Maven release, and include guidance for users to build locally the liboscal-java and oscal-cli using the latest OSCAL release.

@ermahesh
Copy link
Author

@iMichaela What can I do to ensure this code is merged ?

@iMichaela
Copy link

@iMichaela What can I do to ensure this code is merged ?

The PR cannot be merged as long as the tests performed by the CI/CD pipeline are not passing and the locally generated oscal-cli is tested. So far, the CI/CD pipeline has plenty of error which @selenaxiao-nist reproduced locally too when she tried to build the tool locally (without code release tests). She can provide more updates. You can work with her directly if you believe your code is not generating any errors when you build it locally. I am suggesting a v-meeting - please send an email to oscal@nist.gov to connect with our team.

@ermahesh
Copy link
Author

ermahesh commented Jul 1, 2025

@ermahesh Please change PrettyPrinter class to use SaxonTransformerFactory. Refer to XMLOperations class
I made this change

@iMichaela iMichaela requested a review from selenaxiao-nist July 1, 2025 19:16
@selenaxiao-nist
Copy link

@ermahesh Please change PrettyPrinter class to use SaxonTransformerFactory. Refer to XMLOperations class
I made this change

Are you able to build this locally with no errors? Do your unit tests pass?

@rsherwood-nist
Copy link

It appears that pretty printing only works for profile resolution. Is there a reason that the feature was only implemented in that code path, or am I misreading the PR?

@ermahesh
Copy link
Author

ermahesh commented Jul 4, 2025

It appears that pretty printing only works for profile resolution. Is there a reason that the feature was only implemented in that code path, or am I misreading the PR?

@rsherwood-nist This is my first contribution to the project — could you please help me understand if this fix needs to be applied in other parts of the codebase as well.

david-waltermire added a commit to metaschema-framework/oscal-cli that referenced this pull request Dec 5, 2025
This feature enables formatted XML, JSON, and YAML output for the
resolve-profile command, improving readability of the generated files.

- Added PrettyPrinter utility class for formatting output files
- Added --pretty-print CLI option to AbstractResolveCommand
- Added unit tests for the PrettyPrinter utility
- Added CLI integration tests for pretty-print functionality

Original contribution by Mahesh Kumar Gaddam (ermahesh)
Based on usnistgov/oscal-cli#295
Addresses usnistgov/oscal-cli#268
david-waltermire added a commit to metaschema-framework/oscal-cli that referenced this pull request Dec 10, 2025
This feature enables formatted XML, JSON, and YAML output for the
resolve-profile command, improving readability of the generated files.

- Added PrettyPrinter utility class for formatting output files
- Added --pretty-print CLI option to AbstractResolveCommand
- Added unit tests for the PrettyPrinter utility
- Added CLI integration tests for pretty-print functionality

Original contribution by Mahesh Kumar Gaddam (ermahesh)
Based on usnistgov/oscal-cli#295
Addresses usnistgov/oscal-cli#268
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.

4 participants