diff options
| author | Lex Neva <github.com@lexneva.name> | 2018-04-12 20:05:01 -0400 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2018-04-15 19:46:22 -0400 |
| commit | d323059b9db610ac0dda23475729cde5f5c0a619 (patch) | |
| tree | 69bbf029e99c62acd53028d5199082af0bc5a443 | |
| parent | af4573c79cf4136701e7b7feb4a6306270d263cf (diff) | |
always add inkstitch XML namespace
| -rw-r--r-- | inkstitch/extensions.py | 21 |
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()) |
