From 435aab18e26f3b3388d4d69f8eab7bd85aae5c80 Mon Sep 17 00:00:00 2001 From: acspike Date: Sat, 5 Jan 2008 20:48:18 +0000 Subject: [PATCH] add uri for xml namespace and use inkex.addNS() to add namespaces partial fix for Bug #179770 --- share/extensions/gears.py | 4 ++-- share/extensions/inkex.py | 17 +++++++++-------- share/extensions/lorem_ipsum.py | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/share/extensions/gears.py b/share/extensions/gears.py index 9a69bf06e..c60f63b83 100644 --- a/share/extensions/gears.py +++ b/share/extensions/gears.py @@ -149,14 +149,14 @@ class Gears(inkex.Effect): # Embed gear in group to make animation easier: # Translate group, Rotate path. t = 'translate(' + str( self.view_center[0] ) + ',' + str( self.view_center[1] ) + ')' - g_attribs = {'inkscape:label':'Gear' + str( teeth ), + g_attribs = {inkex.addNS('label','inkscape'):'Gear' + str( teeth ), 'transform':t } g = inkex.etree.SubElement(self.current_layer, 'g', g_attribs) # Create SVG Path for gear style = { 'stroke': '#000000', 'fill': 'none' } gear_attribs = {'style':simplestyle.formatStyle(style), 'd':path} - gear = inkex.etree.SubElement(g, 'svg:path', gear_attribs ) + gear = inkex.etree.SubElement(g, inkex.addNS('path','svg'), gear_attribs ) e = Gears() e.affect() diff --git a/share/extensions/inkex.py b/share/extensions/inkex.py index a4ffd8bd3..61cbacea8 100755 --- a/share/extensions/inkex.py +++ b/share/extensions/inkex.py @@ -23,13 +23,14 @@ import sys, copy, optparse, random, re #a dictionary of all of the xmlns prefixes in a standard inkscape doc NSS = { -u'sodipodi' :u'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd', -u'cc' :u'http://web.resource.org/cc/', -u'svg' :u'http://www.w3.org/2000/svg', -u'dc' :u'http://purl.org/dc/elements/1.1/', -u'rdf' :u'http://www.w3.org/1999/02/22-rdf-syntax-ns#', -u'inkscape' :u'http://www.inkscape.org/namespaces/inkscape', -u'xlink' :u'http://www.w3.org/1999/xlink' +u'sodipodi' :u'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd', +u'cc' :u'http://web.resource.org/cc/', +u'svg' :u'http://www.w3.org/2000/svg', +u'dc' :u'http://purl.org/dc/elements/1.1/', +u'rdf' :u'http://www.w3.org/1999/02/22-rdf-syntax-ns#', +u'inkscape' :u'http://www.inkscape.org/namespaces/inkscape', +u'xlink' :u'http://www.w3.org/1999/xlink', +u'xml' :u'http://www.w3.org/XML/1998/namespace' } #a dictionary of unit to user unit conversion factors @@ -55,7 +56,7 @@ def unittouu(string): try: from lxml import etree except: - sys.exit('The fantabulous lxml wrapper for libxml2 is required by inkex_lxml.py and therefore this extension. Please download the latest version from .') + sys.exit('The fantastic lxml wrapper for libxml2 is required by inkex.py and therefore this extension. Please download and install the latest version from .') def debug(what): sys.stderr.write(str(what) + "\n") diff --git a/share/extensions/lorem_ipsum.py b/share/extensions/lorem_ipsum.py index f4e43108a..115ac4ace 100644 --- a/share/extensions/lorem_ipsum.py +++ b/share/extensions/lorem_ipsum.py @@ -220,9 +220,9 @@ class MyEffect(inkex.Effect): if found==0: #inkex.debug('No "flowRoot" elements selected. Unable to add text.') svg=self.document.getroot() - gattribs = {'inkscape:label':'lorem ipsum','inkscape:groupmode':'layer'} + gattribs = {inkex.addNS('label','inkscape'):'lorem ipsum',inkex.addNS('groupmode','inkscape'):'layer'} g=inkex.etree.SubElement(svg,inkex.addNS('g','svg'),gattribs) - flowRoot=inkex.etree.SubElement(g,inkex.addNS('flowRoot','svg'),{'xml:space':'preserve'}) + flowRoot=inkex.etree.SubElement(g,inkex.addNS('flowRoot','svg'),{inkex.addNS('space','xml'):'preserve'}) flowRegion=inkex.etree.SubElement(flowRoot,inkex.addNS('flowRegion','svg')) rattribs = {'x':'0','y':'0','width':svg.get('width'),'height':svg.get('height')} rect=inkex.etree.SubElement(flowRegion,inkex.addNS('rect','svg'),rattribs) -- 2.30.2