summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inkstitch/extensions.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/inkstitch/extensions.py b/inkstitch/extensions.py
index 7795abb8..d48fcc8c 100644
--- a/inkstitch/extensions.py
+++ b/inkstitch/extensions.py
@@ -101,3 +101,24 @@ class InkstitchExtension(inkex.Effect):
patches.extend(element.embroider(last_patch))
return patches
+
+ def parse(self):
+ """Override inkex.Effect to add Ink/Stitch xml namespace"""
+
+ # SVG parsers don't actually look for anything at this URL. They just
+ # care that it's unique. That defines a "namespace" of element and
+ # attribute names to disambiguate conflicts with element and
+ # attribute names other XML namespaces.
+ #
+ # Updating inkex.NSS here allows us to pass 'inkstitch' into
+ # inkex.addNS().
+ inkex.NSS.update('inkstitch', 'http://inkstitch.org/namespace')
+
+ # call the superclass's method first
+ inkex.Effect.parse(self)
+
+ # This is the only way I could find to add a namespace to an existing
+ # element tree at the top without getting ugly prefixes like "ns0".
+ inkex.etree.cleanup_namespaces(inkex.document,
+ top_nsmap=inkex.NSS,
+ keep_ns_prefixes=inkex.NSS.keys())