conversion to HTML5 canvas fails with python stacktrace

Bug #1446204 reported by JVD on 2015-04-20
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Medium
Alvin Penner

Bug Description

Traceback (most recent call last):
  File "ink2canvas.py", line 89, in <module>
    ink.affect()
  File "/usr/local/share/inkscape/extensions/inkex.py", line 268, in affect
    self.effect()
  File "ink2canvas.py", line 84, in effect
    self.walk_tree(svg_root)
  File "ink2canvas.py", line 62, in walk_tree
    tag = self.get_tag_name(node)
  File "ink2canvas.py", line 38, in get_tag_name
    return node.tag.split("}")[1]
AttributeError: 'builtin_function_or_method' object has no attribute 'split'

JVD (jason-vas-dias) wrote :

Trying to save the attached file as an HTML5 canvas resulted in the above python traceback, after
building inkscape 0.91 from source on an up-to-date Ubuntu 14.1 Linux x86_64 system .

su_v (suv-lp) wrote :

Did you forget to attach the test case (Inkscape SVG file)?

Changed in inkscape:
status: New → Incomplete
tags: added: exporting extensions-plugins
JVD (jason-vas-dias) wrote :

Yes , sorry, here it is . This was originally produced with SVG-Edit , and then imported into inkscape, and then I've been trying
to save it in a variety of formats: 1) Inkscape SVG (attached) 2) "Plain SVG" 3) "Optimized SVG" in order to produce a version
that can be included in an HTML5 document and pass the W3C validator: http://validator.w3.org when no success so far.

JVD (jason-vas-dias) wrote :

I'm mainly trying to get rid of the 'se_type' element, which was added by SVG-Edit, but causes validation errors -
but how to do so while preserving the arrows ?

su_v (suv-lp) on 2015-04-20
Changed in inkscape:
status: Incomplete → New
JVD (jason-vas-dias) wrote :
Download full text (3.4 KiB)

How can I include an SVG element produced by inkscape in an HTML5 document without resulting in a document that does not pass HTML5
validation ?

The following notes and warnings highlight missing or conflicting information which caused the validator to perform some guesswork prior to validation, or other things affecting the output below. If the guess or fallback is incorrect, it could make validation results entirely incoherent. It is highly recommended to check these potential issues, and, if necessary, fix them and re-validate the document.

    Info Using experimental feature: HTML5 Conformance Checker.

    The validator checked your document with an experimental feature: HTML5 Conformance Checker. This feature has been made available for your convenience, but be aware that it may be unreliable, or not perfectly up to date with the latest development of some cutting-edge technologies. If you find any issues with this feature, please report them. Thank you.

↑ Top
Validation Output: 5 Errors

    Error Line 10, Column 259: Attribute xmlns:rdf not allowed here.

    … xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="0 0 708.66142 354.33071">

    ✉
    Warning Line 10, Column 259: Attribute with the local name xmlns:rdf is not serializable as XML 1.0.

    … xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="0 0 708.66142 354.33071">

    ✉
    Error Line 10, Column 259: Attribute xmlns:cc not allowed here.

    … xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="0 0 708.66142 354.33071">

    ✉
    Warning Line 10, Column 259: Attribute with the local name xmlns:cc is not serializable as XML 1.0.

    … xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="0 0 708.66142 354.33071">

    ✉
    Error Line 10, Column 259: Attribute xmlns:dc not allowed here.

    … xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="0 0 708.66142 354.33071">

    ✉
    Warning Line 10, Column 259: Attribute with the local name xmlns:dc is not serializable as XML 1.0.

    … xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="0 0 708.66142 354.33071">

    ✉
    Warning Line 31, Column 11: Element name rdf:rdf cannot be represented as XML 1.0.

      <rdf:RDF>

    ✉
    Error Line 31, Column 11: Element rdf:rdf not allowed as child of element metadata in this context. (Suppressing further errors from this subtree.)

      <rdf:RDF>

    ✉
    Warning Line 32, Column 25: Attribute rdf:about is not serializable as XML 1.0.

       <cc:Work rdf:about="">

    ✉
    Warning Line 32, Column 25: Element name cc:work cannot be represented as XML 1.0.

       <cc:Work rdf:about="">

    ✉
    Warning Line 33, Column 15: Element name dc:format cannot be represented as XML 1.0.

        <dc:format>image/svg+xml</dc:format>

    ✉
    Warning Line 34, Column 68: Attribute rdf:resource is not serializable as XML 1.0.

        <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>

    ✉
    Warning Line 34, Column 68: Element name dc:type cannot be represented as XML 1.0.

        <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>

    ✉
    Warning Line 35, Column 15: Element name dc:title cannot be represented as XML 1.0.

        ...

Read more...

su_v (suv-lp) wrote :

Could you please also attach the original SVG file which was created with SVG-Edit? Does SVG-Edit have an option to export as Plain SVG (without custom attributes)? Or an option to save the attributes in a (declared) custom namespace?

In Inkscape 0.91, you can get rid of invalid (not part of the SVG spec, not declared in a custom namespace) attributes by using the SVG output options as listed in the bottom half of 'Edit > Preferences > Input/Output > SVG Output' (delete e.g. on write).

JVD (jason-vas-dias) wrote :
JVD (jason-vas-dias) wrote :
Download full text (4.0 KiB)

When I saved the svg with the options you suggest, I still get @ 190 validation errors, for things like :

    Error Line 8, Column 221: Attribute xmlns:rdf not allowed here.

    …c="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">

    ✉
    Warning Line 8, Column 221: Attribute with the local name xmlns:rdf is not serializable as XML 1.0.

    …c="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">

    ✉
    Error Line 8, Column 221: Attribute xmlns:cc not allowed here.

    …c="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">

    ✉
    Warning Line 8, Column 221: Attribute with the local name xmlns:cc is not serializable as XML 1.0.

    …c="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">

    ✉
    Error Line 8, Column 221: Attribute xmlns:dc not allowed here.

    …c="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">

    ✉
    Warning Line 8, Column 221: Attribute with the local name xmlns:dc is not serializable as XML 1.0.

    …c="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">

    ✉
    Warning Line 10, Column 11: Element name rdf:rdf cannot be represented as XML 1.0.

      <rdf:RDF>

    ✉
    Error Line 10, Column 11: Element rdf:rdf not allowed as child of element metadata in this context. (Suppressing further errors from this subtree.)

      <rdf:RDF>

    ✉
    Warning Line 11, Column 25: Attribute rdf:about is not serializable as XML 1.0.

       <cc:Work rdf:about="">

    ✉
    Warning Line 11, Column 25: Element name cc:work cannot be represented as XML 1.0.

       <cc:Work rdf:about="">

    ✉
    Warning Line 12, Column 15: Element name dc:format cannot be represented as XML 1.0.

        <dc:format>image/svg+xml</dc:format>

    ✉
    Warning Line 13, Column 68: Attribute rdf:resource is not serializable as XML 1.0.

        <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>

    ✉
    Warning Line 13, Column 68: Element name dc:type cannot be represented as XML 1.0.

        <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>

    ✉
    Warning Line 14, Column 15: Element name dc:title cannot be represented as XML 1.0.

        <dc:title/>

    ✉
    Error Line 95, Column 164: Bad value null for attribute stroke-linejoin on element rect.

    …p="null" stroke-dasharray="null" y="101" x="241" stroke-width="2" fill="none"/>

    ✉
    Error Line 95, Column 164: Bad value null for attribute stroke-linecap on element rect.

    …p="null" stroke-dasharray="null" y="101" x="241" stroke-width="2" fill="none"/>

    ✉
    Error Line 96, Column 163: Bad value null for attribute stroke-linejoin on element rect.

    …p="null" stroke-dasharray="null" y="178" x="260" stroke-width="2" fill="none"/>

    ✉
    Error Line 96, Column 163: Bad value null for attribute stroke-linecap on element rect.

    …p="null" stroke-dasharray="null" y="178" x="260" stroke-width="2" fill="none"/>

    ✉
    Error Line 97, Column 161: Bad value null for attribute stroke-linejoin on element ellipse.

    …00000" cy="261" cx="263" stroke-dasharray="null" s...

Read more...

su_v (suv-lp) wrote :

You filed bug #1446209 already about problems with the w3c validator handling inline SVG - could we please keep focus on the reported issue in each of your reports? This one was filed for an export failure of the output extension to convert SVG into HTML5 canvas (python script failure); the validation problems have been reported separately as bug #1446209.

--
<off-topic>
Attaching the output of the validator saved as plain-text file would keep the reports more readable, instead of huge inline pastes
</off-topic>

Alvin Penner (apenner) wrote :

original Python error message confirmed on recent Inkscape trunk using the file WL-CI_PT_process.svg.

It appears the Python error message was caused by the following comment line in the svg, can be temporarily avoided by removing this line:

<!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->

Changed in inkscape:
status: New → Confirmed
Alvin Penner (apenner) wrote :

attached is a new version of ink2canvas.py which avoids the Python error caused by the html comment.
It can be tested by copying it into the directory Inkscape\share\extensions\

Alvin Penner (apenner) wrote :

committed to rev 14059

Changed in inkscape:
status: Confirmed → Fix Committed
assignee: nobody → Alvin Penner (apenner)
su_v (suv-lp) on 2015-04-22
Changed in inkscape:
milestone: none → 0.92
importance: Undecided → Medium
tags: added: backport-proposed
removed: exporting
ScislaC (scislac) wrote :

trunk r14059 backported in 0.91.x r13750

Changed in inkscape:
milestone: 0.92 → 0.91.1
su_v (suv-lp) on 2015-04-27
tags: removed: backport-proposed
jazzynico (jazzynico) on 2017-01-28
Changed in inkscape:
milestone: 0.91.1 → 0.92
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers