You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the xml (spec)[https://www.w3.org/TR/2006/REC-xml-names11-20060816/#sec-namespaces]:
The namespace prefix, unless it is xml or xmlns, must have been declared in a namespace declaration attribute in either the start-tag of the element where the prefix is used or in an ancestor element (i.e. an element in whose content the prefixed markup occurs). Furthermore, the attribute value in the innermost such declaration must not be an empty string.
Though it is admittedly harder to read, these two declarations should be both valid uses of the prefix: <div xmlns:epub="http://www.idpf.org/2007/ops" epub:type="footnote">Test</div> <div epub:type="footnote" xmlns:epub="http://www.idpf.org/2007/ops">Test</div>
Unfortunately, the way that the parser works, it parses attributes in the order they are declared, so the first example parses correctly to the expected namespace uri, but the second one does not.
First, we could make sure to process any namespace declarations before any other attributes, which seems like the simplest approach. I have a PR to this effect that I will put up for your review.
Second, we could do a second run through the created attributes, double checking the namespaces after all the attributes have been processed.
The text was updated successfully, but these errors were encountered:
Bug Report
According to the xml (spec)[https://www.w3.org/TR/2006/REC-xml-names11-20060816/#sec-namespaces]:
Though it is admittedly harder to read, these two declarations should be both valid uses of the prefix:
<div xmlns:epub="http://www.idpf.org/2007/ops" epub:type="footnote">Test</div>
<div epub:type="footnote" xmlns:epub="http://www.idpf.org/2007/ops">Test</div>
Unfortunately, the way that the parser works, it parses attributes in the order they are declared, so the first example parses correctly to the expected namespace uri, but the second one does not.
Prerequisites
AngleSharp.Css
for CSS support)For more information, see the
CONTRIBUTING
guide.Description
Namespace declarations need to be parsed before other attributes on an element.
Steps to Reproduce
Expected behavior: both
Dump()
calls should print outhttp://www.idpf.org/2007/ops
.Actual behavior: the first call to
Dump()
outputs the correct uri, the second outputsnull
.Environment details: Win 10 .NET 6.0.15
Possible Solution
There are two approaches that could be taken, both around
AngleSharp.Xml/src/AngleSharp.Xml/Parser/XmlDomBuilder.cs
Lines 277 to 282 in 65fc194
First, we could make sure to process any namespace declarations before any other attributes, which seems like the simplest approach. I have a PR to this effect that I will put up for your review.
Second, we could do a second run through the created attributes, double checking the namespaces after all the attributes have been processed.
The text was updated successfully, but these errors were encountered: