-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
XmlWriterSettings.NewLineOnAttributes
is ignored on writing xmlns:*
attributes
#74840
Comments
Tagging subscribers to this area: @dotnet/area-system-xml Issue DetailsDescriptionAs described in the title. This problem seems to occur with both case of Reproduction StepsCode for reproduction: using System.Xml;
using System.Xml.Linq;
var nsSvg = (XNamespace)"http://www.w3.org/2000/svg";
var nsXLink = (XNamespace)"http://www.w3.org/1999/xlink";
var doc = new XDocument(
new XDeclaration("1.0", "utf-8", null),
new XElement(
nsSvg + "svg",
new XAttribute("version", "1.1"),
new XAttribute("width", "10"),
new XAttribute(XNamespace.Xmlns + "xlink", nsXLink.NamespaceName),
new XAttribute("height", "10"),
new XElement(nsSvg + "g")
)
);
var settings = new XmlWriterSettings() {
CloseOutput = false,
Indent = true,
IndentChars = " ",
NewLineChars = "\n",
NewLineOnAttributes = true
};
using (var writer = XmlWriter.Create(Console.Out, settings)) {
doc.Save(writer);
}
Console.WriteLine(); Note: The same problem occurs with
Expected behavior<?xml version="1.0" encoding="utf-8"?>
<svg
version="1.1"
width="10"
xmlns:xlink="http://www.w3.org/1999/xlink"
height="10"
xmlns="http://www.w3.org/2000/svg">
<g />
</svg> Actual behavior<?xml version="1.0" encoding="utf-8"?>
<svg
version="1.1"
width="10" xmlns:xlink="http://www.w3.org/1999/xlink"
height="10" xmlns="http://www.w3.org/2000/svg">
<g />
</svg> Regression?No response Known WorkaroundsNo response Configuration
Other informationNo response
|
Hey @smdn, it does looks like a bug although since this behavior hasn't changed probably for at least 10 years we probably won't pick this up. I'll recommend to create a PR if you're interested in this. I'd also recommend starting out testing directly with XmlWriter since it's most likely where this originates from. |
@krwq, thank you for telling me the background. For now, I will try to handle this by creating custom XmlWriter or something. Thanks! |
Description
As described in the title.
XmlWriterSettings.NewLineOnAttributes
is applied to normal attributes properly, but seems not to be applied toxmlns
attributes.This problem seems to occur with both case of
xmlns="..."
andxmlns:nsname="..."
.Reproduction Steps
Code for reproduction:
Note: The same problem occurs with
XDocument
created fromXDocument.Load
.Expected behavior
Actual behavior
Regression?
No response
Known Workarounds
No response
Configuration
Other information
No response
The text was updated successfully, but these errors were encountered: