[Ill] newlines between elements cause phantom xml nodes

Bug #167125 reported by Nix-nix
16
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Invalid
Low
Unassigned

Bug Description

...
<path
   d=""
   stroke-miterlimit="10"
   id="path6779"

style="fill:none;stroke:#000000;stroke-width:0.99900001;stroke-miterlimit:1
0.000000"
/><path
   d=""
   stroke-miterlimit="10"
   id="path6783"

style="fill:none;stroke:#000000;stroke-width:0.99900001;stroke-miterlimit:1
0.000000"
/><path
   d=""
   stroke-miterlimit="10"
   id="path6835"

style="fill:none;stroke:#000000;stroke-width:0.99900001;stroke-miterlimit:1
0.000000"
/>
 <path
   d=""
   stroke-miterlimit="10"
   id="path17"

style="fill:none;stroke:#000000;stroke-width:0.99900001;stroke-miterlimit:1
0.000000"
/><path
   d=""
   stroke-miterlimit="10"
   id="path29"

style="fill:none;stroke:#000000;stroke-width:0.99900001;stroke-miterlimit:1
0.000000"
/>
...

Notice the difference in whitespace between path6835
and path17 as opposed to the whitespace between any
other 2 consecutive paths ?

This causes a phantom tag to appear in the XML editor:
...
<svg:path id="path6783">
<svg:path id="path6835">
    "
<svg:path id="path17">
<svg:path id="path29">
...

Adobe illustrator seems to format SVG this way, which,
in turn causes inkscape to litter the XML editor with
these phantom tags. Also, svg2pdf (from the cairo
project) ends up segfaulting. However, tediously
scrolling through the XML editor and removing these
phantom tags or, alternatively, opening the SVG in a
text editor and re-formatting it causes the phantom
tags to disappear and svg2pdf to work properly.

It looks like the phantom tags appear because of the
misinterpretation of the SVG file induced by the
strange arrangement of whitespace. The SVG file itself
does not appear malformed.

It would be really nice if inkscape could properly
interpret the whitespace because it could then save the
SVG file in a svg2pdf-friendly fashion.

Tags: ui xmleditor
Revision history for this message
Nix-nix (nix-nix) wrote :
Revision history for this message
Buliabyak-users (buliabyak-users) wrote :

I don't really think we should "fix" this. These "phantom
nodes" do not cause any erroneous behavior in Inkscape
itself. As for XML editor, it just correctly shows
everything there is in the document, including whitespace
nodes.

Revision history for this message
Nix-nix (nix-nix) wrote :

It is true that those "whitespace nodes" do not affect
inkscape's behaviour, however those "whitespace nodes" are
not nodes at all. They are merely whitespace and, IINM, XML
states that whitespace is to be ignored, not interpreted as
a node.

I mean,
"<node/> <node/>" != "<node/><whitespace/><node/>"

Also, while they do not affect inkscape, they do affect
inkscape's interoperability with other programs: in this
case, svg2pdf.

I understand that all of this is really Illustrator's fault,
however, that's no reason to avoid improving what is (IMO)
the best OSS alternative to Illustrator, especially now that
there's svg2pdf.

Revision history for this message
Buliabyak-users (buliabyak-users) wrote :

You're right, SVG states that whitespace must be ignored by
default (unless there's xml:space="preserve"). But in
practice this only affects how text is displayed in <text>
element:

http://www.w3.org/TR/SVG11/text.html#WhiteSpace

and it never says that an XML processor must _strip_ this
whitespace. Just ignore when displaying, which is what
Inkscape does. On the other hand, XML says

http://www.w3.org/TR/2004/REC-xml-20040204/#sec-white-space

that it's OK to use whitespace for formatting. No one is
obliged to strip it. In fact, I think it will be wrong to
strip it without asking. So the worst offender in this
situation is not Inkscape and not even AI, but the svg2pdf
which, according to XML/SVG specs, must ignore these
newlines instead of crashing on them.

How our XML editor displays the whitespace nodes is another,
purely cosmetic issue. Even if we suppress the display of
these phantom nodes, we should strive to preserve the
formatting whitespace in the open/write cycle as much as
possible.

Revision history for this message
Nix-nix (nix-nix) wrote :

*bow head* ... I agree that the scope of the bug should be
reduced to that of a display problem in the XML editor.
Nonetheless, I would still like to see the XML editor
suppress those "phantom nodes", because they are not nodes
at all but merely, as the spec states, whitespace used for
formatting, and a situation should never arise where some
whitespace gets interpreted as a node whereas other
whitespace does not.

Inkscape ignores whitespace when displaying an SVG file, but
it's XML editor also "displays" the same SVG file and
should, therefore also ignore whitespace.

Also, upon further investigation, it turns out that it is
the presence of "metadata" nodes and such that end up
killing svg2pdf, rather than the presence of the whitespace,
as I originally thought.

Revision history for this message
vonHalenbach (lustik) wrote :

I can confirm it on SVN 16763. The space must not be interpreted as node.

Changed in inkscape:
status: New → Confirmed
su_v (suv-lp)
tags: added: xmleditor
Revision history for this message
Patrick Storz (ede123) wrote :

First of all I'm calmed by the fact that this is only a cosmetic issue. When I saw the empty nodes in XML editor I was afraid that there was an error parsing the XML therefore potentially damaging the SVG if further working with it.

That's also why i think this should definitely be fixed (It's probably not that hard to simply hide the empty nodes in XML editor?).

An even if one nows that this is only a cometic issue, it stays a usability issue after all. It's already hard enough to keep track of a complex XML tree, a bunch of blank nodes in between really doesn't improve the situation.

Revision history for this message
Nathan Lee (nathan.lee) wrote :

Hi - thanks for reporting this bug, I've manually migrated it to Inkscape's new bug tracker on GitLab, and closed it here (wow, almost 15 years old bug)

Please feel free to file new bugs about the issues you're seeing at
http://inkscape.org/report.

Moved to: https://gitlab.com/inkscape/inbox/-/issues/1992

Changed in inkscape:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.