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

explore using libxml2's xmlReconciliateNs() to deal with reparenting #2919

Open
flavorjones opened this issue Jul 3, 2023 · 3 comments
Open

Comments

@flavorjones
Copy link
Member

flavorjones commented Jul 3, 2023

Currently Nokogiri tries to figure out namespaces after node reparenting via our homebrewed function node.c:relink_namespace(), however what we're doing there is probably not quite right as evidenced by the number of issues as well as the commentary on a few PRs, notably #2495 and #2310.

Recently I discovered that libxml2 has a method, xmlReconciliateNs(), which seems to do what we want (from a brief reading).

This issue is to explore using xmlReconciliateNs() with careful attention paid to:

  • does this fix some of the issues reported
  • does this break existing tests
  • does this break downstream consumers of Nokogiri
@nwellnhof
Copy link

xmlReconciliateNs isn't used much. It has a weird way to resolve namespace clashes and is still buggy.

@flavorjones
Copy link
Member Author

@nwellnhof Thanks, I just came back to this issue to link to your comment from #613.

It's still something I'd like to explore -- I'm not at all convinced that what Nokogiri is doing today is better. And if I discover edge cases I might be able to help contribute to an updated/new implementation.

@nwellnhof
Copy link

Another option, but probably even less tested, is xmlDOMWrapAdoptNode. This function seems to implement W3C DOM Namespace Normalization and should be called before moving a node. There's also xmlDOMWrapReconcileNamespaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants