-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Task XslTransformation: How to specify XmlSpace.Preserve? #7671
Comments
Team triage: Nice analysis! We would accept a new argument to the task that passes a bool down to that call. |
Are the parameters specified in the
Update: fixed it by modifying the public API files |
`PreserveWhitespace` option to use `XmlSpace.Preserve` with `XPathDocument`.
That's correct; there is some documentation on task invocation and if you want the details you might be interested in
That was almost perfect; I'm making a suggestion in your PR. |
PreserveWhitespace option to use XmlSpace.Preserve with XPathDocument. Fixes #7671 Context Should fix whitespace issue with XSLT files Changes Made Adding a new public property to the class XslTransformation. If it PreserveWhitespace is set to true, the produced file will preserve whitespaces.
Issue Description
The MSBuild Task XslTransformation (docs, source) always loads the provided XSLT file with
XmlSpace.Default
. I would like to useXmlSpace.Preserve
instead.Steps to Reproduce
See this project. It contains an XSL stylesheet, an input XML file, and a dotnet project that generates two output files: one with the XslTransformation task, one in
Program.cs
. It also contains both output files so you can see the difference in GitHub.You can clone the repo, delete the generated files, and run
dotnet run
to re-generate them.Expected Behavior
Both files have the same content.
Actual Behavior
The MSBuild Task does not preserve whitespace and offers no way to change this behavior (at least none that I was able to find).
Analysis
The desired behavior can be achieved by changing
new XPathDocument(reader)
tonew XPathDocument(reader, XmlSpace.Preserve)
in this line.I'm happy that
XmlSpace.Default
is the default. But I'd like to have an option to useXmlSpace.Preserve
instead, e.g. via<XslTransformation PreserveWhitespace="true" ... />
.Versions & Configurations
To reproduce this, I use the dotnet CLI without IDE.
dotnet --version
: 6.0.300The text was updated successfully, but these errors were encountered: