corba22 / eggbotcode

Automatically exported from code.google.com/p/eggbotcode
0 stars 0 forks source link

XML comment tags generate report of an object which needs to be converted to a <path> #28

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
If there is an XML comment (or processing instruction) buried in the SVG 
document, this can cause recursivelyTraverseSvg() to issue a warning while 
plotting about an element which needs to be converted to a path.  This, because 
the XML comment node shows up as an SVG "element" we don't recognize.  (It's 
not actually an XML "element" per se.)

Detecting this is easy enough in eggbot.py, albeit not immediately obvious.  We 
need to use an instanceof() check t see if the node's "tag" in the lxml.etree 
we're traversing is of type "basestring" or not.  If it is, then it's some sort 
of XML element.  If it isn't, then it's a processing direction or comment which 
we can ignore.

>>> a=lxml.etree.XML("<a><!-- comment --><b/></a>")
>>> a[0].tag
<built-in function Comment>
>>> a[1].tag
'b'
>>> isinstance(a[0].tag, basestring)
False
>>> isinstance(a[1].tag, basestring)
True
>>> 

Original issue reported on code.google.com by newman.d...@gmail.com on 17 Oct 2010 at 9:44

GoogleCodeExporter commented 8 years ago

Original comment by newman.d...@gmail.com on 17 Oct 2010 at 10:17