KanjiVG / kanjivg

Kanji vector graphics
http://kanjivg.tagaini.net
Other
1.06k stars 181 forks source link

XML namespace undefined. #32

Closed ospalh closed 10 years ago

ospalh commented 12 years ago

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 "):]

(See the W3C recommendation for tons of boring details on XML namespaces.)

ospalh commented 10 years ago

OK, i looked into DTDs, and defining the namespace there, as is done in the data, seems OK.. May be a problem with other tools.