The kanjivg.xml file produced by kvg.py produces an error when you try to parse it, for example with Pythons ElementTree, xml.etree.ElementTree.parse(kanjiVgFile) (with the file open and xml imported): “xml.etree.ElementTree.ParseError: unbound prefix: line 425, column 0”
The reason appears to be that the “kvg:” XML namespace isn’t defined.
Adding a xmlns to the kanjivg tag seems to help:
index 5ad048b..85dd1e6 100755
--- a/kvg.py
+++ b/kvg.py
@@ -75,7 +75,7 @@ def release():
out.write(licenseString)
out.write("\nThis file has been generated on %s, using the latest KanjiVG data\nto this date." % (dat
out.write("\n-->\n")
- out.write("<kanjivg>\n")
+ out.write('<kanjivg xmlns:kvg="http://kanjivg.tagaini.net/format.html">\n')
for f in files:
data = open(os.path.join(datadir, f)).read()
data = data[data.find("<svg "):]
The kanjivg.xml file produced by kvg.py produces an error when you try to parse it, for example with Pythons ElementTree,
xml.etree.ElementTree.parse(kanjiVgFile)
(with the file open and xml imported): “xml.etree.ElementTree.ParseError: unbound prefix: line 425, column 0
”The reason appears to be that the “
kvg:
” XML namespace isn’t defined. Adding axmlns
to the kanjivg tag seems to help:(See the W3C recommendation for tons of boring details on XML namespaces.)