xml2rfc
xml2rfc copied to clipboard
"Warning: Duplicate attribute id" unnecessary for id attributes that are unique to an SVG tree node?
Describe the issue
When xml2rfc is run on [1], it produces many, many warnings that have the form of:
Warning: Duplicate attribute id="E1-STIXWEBMAIN-3D" found after including svg
from inline:b'<svg xmlns:xlink="http://www.w3' .... This can cause problems with some browsers.
There are multiple SVG drawings in [1] that are reusing shapes that have been defined by <path>
elements (for instance, E1-STIXWEBMAIN-3D is a thin, horizontal rectangle). These <path>
elements have id attributes that are unique to each SVG node tree; however, xml2rfc complains. I think these warnings may be incorrect. All major browsers support the id attribute [2], and this document is not using svgViewElement. The output appears fine in Firefox.
[1] https://www.rfc-editor.org/v3test/draft-ietf-tcpm-rfc8312bis-15.xml [2] https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/id
Code of Conduct
- [X] I agree to follow the IETF's Code of Conduct
The warning is correct.
In HTML specs, id
must be unique for the document [1].
These SVG drawings are embedded in HTML and are part of the final document.
[1] https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id
W3C HTML validator reports these as errors: https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.rfc-editor.org%2Fv3test%2Fdraft-ietf-tcpm-rfc8312bis-15.html
Hrm, okay, we can share that with the authors. Is this something svgcheck should look for then? Because svgcheck thinks the SVG in the document is valid.
Is this something svgcheck should look for then? Because svgcheck thinks the SVG in the document is valid.
Maybe... Because each SVG is valid on its own. This becomes a problem when all of them are combined to gather.
I don't know if we need to ask authors to put a bunch of effort into making their ids across svg documents unique.
Backing out to the original ask in the issue : can we perhaps build a mode (make it default?) where xml2rfc reports on the number of types of warnings vs dumping all of them? Or make it where the invoker can selectively suppress warnings?
So, what action should the RPC take when we encounter this warning? Ask the authors to change the ids within the SVG so that they are unique across all SVG within a given document? Or, disregard this warning?
Example: https://www.ietf.org/archive/id/draft-ietf-elegy-rfc8989bis-05.xml
Gives warnings as follows (and many more):
(343): Warning: Duplicate attribute id="E1-STIXWEBMAIN-29" found after including svg from inline:b'<svg xmlns:xlink="http://www.w3' .... This can cause problems with some browsers.
(343): Warning: Duplicate attribute id="E1-STIXWEBSIZE3-28" found after including svg from inline:b'<svg xmlns:xlink="http://www.w3' .... This can cause problems with some browsers.
(343): Warning: Duplicate attribute id="E1-STIXWEBSIZE3-29" found after including svg from inline:b'<svg xmlns:xlink="http://www.w3' .... This can cause problems with some browsers.
On 2023-03-08, at 21:05, Kesara Rathnayake @.***> wrote:
The warning is correct. In HTML specs, id must be unique for the document [1]. These SVG drawings are embedded in HTML and are part of the final document.
[1] https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id
Doing an id= rename across all SVGs might be something that an authoring tool should do, so that xml2rfc actually gets what counts valid XML to start with.
Now https://github.com/cabo/kramdown-rfc/issues/193
Of course, other courses that multiple SVG files generated by the same tool will take will also have the same problem, so maybe I’ll extract the deduplicator as a separate tool that can be employed by these other paths.
Grüße, Carsten
Kramdown-rfc 1.6.28 now has an experimental addition:
$ xml2rfc --html draft-ietf-tcpm-rfc8312bis-15.xml sprint/svg-ids/draft-ietf-tcpm-rfc8312bis-15.xml(490): Warning: Duplicate attribute id="E1-STIXWEBNORMALI-1D461" found after including svg from inline:b'<svg xmlns:xlink="http://www.w3' .... This can cause problems with some browsers. … and tons more …
$ kramdown-rfc-clean-svg-ids draft-ietf-tcpm-rfc8312bis-15.xml >cleaned.xml *** warning: unused ID: #<Set: {"E1-STIXWEBMAIN-7B"}> *** warning: unused ID: #<Set: {"E1-STIXWEBMAIN-7B"}> *** warning: unused ID: #<Set: {"E1-STIXWEBMAIN-7B"}> *** warning: unused ID: #<Set: {"E1-STIXWEBMAIN-7D"}> *** warning: unused ID: #<Set: {"E1-STIXWEBMAIN-28", "E1-STIXWEBMAIN-29"}> *** warning: unused ID: #<Set: {"E1-STIXWEBMAIN-28", "E1-STIXWEBMAIN-29"}> $ xml2rfc --html cleaned.xml Created file cleaned.html
Please ignore the warnings from the tool; there seem to be some superfluous definitions in the SVG elements, which does not hurt (nobody would notice these had I not written some diagnostics into the tool).
As usual,
gem update kramdown-rfc
to get the addition.
Grüße, Carsten
To avoid the need for adding processing pipelines, kramdown-rfc 1.6.29 now has a YAML header option:
svg-id-cleanup: true
More details in: https://github.com/cabo/kramdown-rfc/wiki/SVG#svg-id-collisions
@cabo Thanks for these updates, Carsten. I successfully ran kramdown-rfc-clean-svg-ids on a document that had duplicate IDs to clean them up.