Code

add uri for xml namespace and use inkex.addNS() to add namespaces
authoracspike <acspike@users.sourceforge.net>
Sat, 5 Jan 2008 20:48:18 +0000 (20:48 +0000)
committeracspike <acspike@users.sourceforge.net>
Sat, 5 Jan 2008 20:48:18 +0000 (20:48 +0000)
partial fix for Bug #179770

share/extensions/gears.py
share/extensions/inkex.py
share/extensions/lorem_ipsum.py

index 9a69bf06eaf60a7ddcd74e3e7dcb94e6e9f9eb0c..c60f63b8312b24cb68d42a2f039d2ddc7028047a 100644 (file)
@@ -149,14 +149,14 @@ class Gears(inkex.Effect):
         # Embed gear in group to make animation easier:
         #  Translate group, Rotate path.\r
         t = 'translate(' + str( self.view_center[0] ) + ',' + str( self.view_center[1] ) + ')'\r
-        g_attribs = {'inkscape:label':'Gear' + str( teeth ),\r
+        g_attribs = {inkex.addNS('label','inkscape'):'Gear' + str( teeth ),\r
                    'transform':t }
         g = inkex.etree.SubElement(self.current_layer, 'g', g_attribs)
 
         # Create SVG Path for gear\r
         style = { 'stroke': '#000000', 'fill': 'none' }\r
         gear_attribs = {'style':simplestyle.formatStyle(style), 'd':path}
-        gear = inkex.etree.SubElement(g, 'svg:path', gear_attribs )\r
+        gear = inkex.etree.SubElement(g, inkex.addNS('path','svg'), gear_attribs )\r
 
 e = Gears()
 e.affect()
index a4ffd8bd3fa48db11798c68069fad753cadf0581..61cbacea8af8a64a0be0f6b4d3718a3f22da9972 100755 (executable)
@@ -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 <http://cheeseshop.python.org/pypi/lxml/>.')
+    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 <http://cheeseshop.python.org/pypi/lxml/>.')
 
 def debug(what):
     sys.stderr.write(str(what) + "\n")
index f4e43108ad6d108795fc27a9affcd32a245bd8d2..115ac4acef2e48e95dc5bace745e6db70288b429 100644 (file)
@@ -220,9 +220,9 @@ class MyEffect(inkex.Effect):
     if found==0:\r
       #inkex.debug('No "flowRoot" elements selected. Unable to add text.')\r
       svg=self.document.getroot()\r
-      gattribs = {'inkscape:label':'lorem ipsum','inkscape:groupmode':'layer'}\r
+      gattribs = {inkex.addNS('label','inkscape'):'lorem ipsum',inkex.addNS('groupmode','inkscape'):'layer'}\r
       g=inkex.etree.SubElement(svg,inkex.addNS('g','svg'),gattribs)\r
-      flowRoot=inkex.etree.SubElement(g,inkex.addNS('flowRoot','svg'),{'xml:space':'preserve'})\r
+      flowRoot=inkex.etree.SubElement(g,inkex.addNS('flowRoot','svg'),{inkex.addNS('space','xml'):'preserve'})\r
       flowRegion=inkex.etree.SubElement(flowRoot,inkex.addNS('flowRegion','svg'))\r
       rattribs = {'x':'0','y':'0','width':svg.get('width'),'height':svg.get('height')}\r
       rect=inkex.etree.SubElement(flowRegion,inkex.addNS('rect','svg'),rattribs)\r