Forum How do I...?

SVG warning: Attribute space of element style: already defined

JoeBush
Hi all, I'm processing an RPG book with SVG graphics in it produced in Affinity. When I run it through prince, I get numerous warnings (one per SVG, I think) reading:

prince: http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd:2278: warning: Attribute space of element style: already defined


How do I fix the SVG files or hide the warning? I want my console output to be clean so I can see the output of previous steps prior to running prince without having to scroll up every time. I'm not familiar with hand-coding SVGs, but there may be a setting in affinity I can change if there's something wrong with the SVG, I just don't understand what the problem is. Also, the prince error doesn't really indicate which SVG is the problem, so that makes it harder to track down.
wangp
Which operating system and Prince version are you using?
JoeBush
I'm using prince 16.2 on Linux Mint 22.3 XFCE. I believe I was getting the same warning on windows 10 a few months ago.
wangp
Ok, I managed to recreate it. This occurs with the Ubuntu build which uses the system libxml2, version 2.9.14. The warning does not occur with the linux-generic build, which uses its own copy of libxml2, version 2.12.9. I haven't yet tracked down the difference between the two libxml2 versions, but the simplest solution for you to avoid the warning would be to use the linux-generic Prince build.

The problem is that in /usr/share/xml/svg/svg11.dtd, near line 2278, the style element’s attribute list is defined as:
<!ENTITY % SVG.style.attlist "INCLUDE" >
<![%SVG.style.attlist;[
<!ATTLIST %SVG.style.qname;
    xml:space ( preserve ) #FIXED 'preserve'
    %SVG.Core.attrib;
    type %ContentType.datatype; #REQUIRED
    media %MediaDesc.datatype; #IMPLIED
    title %Text.datatype; #IMPLIED
>
<!-- end of SVG.style.attlist -->]]>

where %SVG.Core.attrib is defined earlier as:
<!ENTITY % SVG.space.attrib
    "xml:space ( default | preserve ) #IMPLIED"
>
...
<!ENTITY % SVG.Core.attrib
    "%SVG.id.attrib;
     %SVG.base.attrib;
     %SVG.lang.attrib;
     %SVG.space.attrib;
     %SVG.Core.extra.attrib;"
>

After parameter entity expansion, %SVG.Core.attrib introduces an additional xml:space declaration for the 'style' element. Since 'style' already declares xml:space explicitly as #FIXED 'preserve', libxml2 detects two declarations of the same attribute on the same element and emits a warning.
JoeBush
Wow, fast work. Thank you!
JoeBush
I've reinstalled the generic version, and can confirm that it does not show the warnings.