Skip to content

Commit

Permalink
default namespaces are nly supported by lxml
Browse files Browse the repository at this point in the history
  • Loading branch information
cleder committed Nov 26, 2013
1 parent e3191e0 commit caff9b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion fastkml/kml.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ def etree_element(self):
root = etree.Element('%skml' % self.ns)
root.set('xmlns', config.NS[1:-1])
else:
root = etree.Element('%skml' % self.ns, nsmap={None:self.ns[1:-1]})
if config.LXML:
root = etree.Element('%skml' % self.ns, nsmap={None:self.ns[1:-1]})
else:
root = etree.Element('%skml' % self.ns)
for feature in self.features():
root.append(feature.etree_element())
return root
Expand Down
2 changes: 1 addition & 1 deletion fastkml/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def test_kml(self):
""" kml file without contents """
k = kml.KML()
self.assertEqual(len( list(k.features())),0)
if hasattr(etree, 'register_namespace'):
if config.LXML:
self.assertEqual( str(k.to_string())[:43],
'<kml xmlns="http://www.opengis.net/kml/2.2"/>'[:43])
else:
Expand Down

0 comments on commit caff9b8

Please sign in to comment.