Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dkg opened this issue May 13, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@dkg
Copy link

dkg commented May 13, 2022

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
@regebro regebro added the bug Something isn't working label Jan 11, 2023
@regebro
Copy link
Contributor

regebro commented Jan 11, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants