Shoobx / xmldiff

A library and command line utility for diffing xml

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

-f xml fails with: "TypeError: empty namespace prefix is not supported in XPath"

dkg opened this issue · comments

commented

I wanted to try adding the argon2 S2K allocation to https://www.iana.org/assignments/pgp-parameters/pgp-parameters.xml, which means adding a row for codepoint 4 in the S2K parameters section, so i fetched it, modified it by hand, and tried to compare the output with xmldiff 2.4 (from debian, version 2.4-2). It worked fine with the diff formatter, but the xml formatter choked with error message
"TypeError: empty namespace prefix is not supported in XPath". Here's a log:

$ xmldiff pgp-parameters.xml.orig pgp-parameters.xml
[insert, /*/*[4], {http://www.iana.org/assignments}record, 7]
[move, /*/*[5]/*[8]/*[1], /*/*[4]/*[8], 0]
[insert, /*/*[4]/*[8], {http://www.iana.org/assignments}description, 1]
[update-text, /*/*[4]/*[8]/*[2], "Argon2"]
[insert, /*/*[4]/*[8], {http://www.iana.org/assignments}xref, 2]
[insert-attribute, /*/*[4]/*[8]/*[3], data, "rfcXXXX"]
[insert-attribute, /*/*[4]/*[8]/*[3], type, "rfc"]
[move, /*/*[18]/*[8]/*[1], /*/*[4]/*[9], 0]
[update-text, /*/*[4]/*[9]/*[1], "5-99"]
[move, /*/*[8]/*[8]/*[1], /*/*[5]/*[8], 0]
[move, /*/*[16]/*[8]/*[1], /*/*[8]/*[8], 0]
[insert, /*/*[16]/*[8], {http://www.iana.org/assignments}value, 0]
[update-text, /*/*[16]/*[8]/*[1], "4"]
[move, /*/*[4]/*[9]/*[2], /*/*[18]/*[8], 0]
$ xmldiff -f xml -p pgp-parameters.xml.orig pgp-parameters.xml
Traceback (most recent call last):
  File "/usr/bin/xmldiff", line 33, in <module>
    sys.exit(load_entry_point('xmldiff==2.4', 'console_scripts', 'xmldiff')())
  File "/usr/lib/python3/dist-packages/xmldiff/main.py", line 116, in diff_command
    result = diff_files(args.file1, args.file2, diff_options=diff_options,
  File "/usr/lib/python3/dist-packages/xmldiff/main.py", line 50, in diff_files
    return _diff(etree.parse, left, right,
  File "/usr/lib/python3/dist-packages/xmldiff/main.py", line 38, in _diff
    return diff_trees(left_tree, right_tree, diff_options=diff_options,
  File "/usr/lib/python3/dist-packages/xmldiff/main.py", line 30, in diff_trees
    return formatter.format(diffs, left)
  File "/usr/lib/python3/dist-packages/xmldiff/formatting.py", line 343, in format
    self.handle_action(action, root)
  File "/usr/lib/python3/dist-packages/xmldiff/formatting.py", line 356, in handle_action
    method(action, result)
  File "/usr/lib/python3/dist-packages/xmldiff/formatting.py", line 467, in _handle_InsertNode
    target = self._xpath(tree, action.target)
  File "/usr/lib/python3/dist-packages/xmldiff/formatting.py", line 398, in _xpath
    for match in node.xpath(path, namespaces=node.nsmap):
  File "src/lxml/etree.pyx", line 1594, in lxml.etree._Element.xpath
  File "src/lxml/xpath.pxi", line 259, in lxml.etree.XPathElementEvaluator.__init__
  File "src/lxml/xpath.pxi", line 131, in lxml.etree._XPathEvaluatorBase.__init__
  File "src/lxml/xpath.pxi", line 55, in lxml.etree._XPathContext.__init__
  File "src/lxml/extensions.pxi", line 81, in lxml.etree._BaseContext.__init__
TypeError: empty namespace prefix is not supported in XPath

I can replicate this, but I'm not yet sure which is the best way to deal with it.