-
-
Notifications
You must be signed in to change notification settings - Fork 903
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
Namespace cache rework #959
Conversation
Looks good. Can you squash these changes into a single commit and remove the whitespace changes? It makes it easier to review, thanks for all the work! |
Lee, Thanks for taking a look at this. I squashed the commits and cleaned up the whitespace issues. |
…parklemotion#940. This allows for namespace prfixes to the redeclared at an element level, allows for default namespaces to be redeclared at an element level and fixes issues related to adding namepsaces delcarations on the document for use in xpath calls
@yokolet Could you review this PR? |
Sure! Give a day or so. |
@rdingwell thanks for working on this! Namespace refactoring has been in my TODO list for a long time. Patch looks good, however, newly skips two tests in xml/test_builder.rb. This will be a regression for some users. Pure Java Nokogiri maintainers have paid a lot of efforts to make it work consistent to CRuby version. Introducing new inconsistency is a bad news for users. |
@yokolet The issue with the skipped tests has to do with this patch allowing for namespace prefixes to be redefined in a document. If you look at #943 you'll see that even CRuby has inconsistencies with what it does when parsing a document with redefined namespace prefixes and what it allows a user to do programmatically. The reason that the 2 tests are skipped is because this patch fixes issue #943 for JRuby Nokogiri, the issue still exists in CRuby Nokogiri though. The tests themselves are specifically looking for not being able to redefine namespaces, which IMO should be allowed seeing how it is allowed by the XML specification. I had started to look at what it would take to do the same for the CRuby implementation but it's been a while since I've done any real C coding and decided to back off on that. I think this is really an issue where the CRuby Nokogiri implementation should be brought up to date and aligned with what this patch fixes. I understand needing to keep things consistent but that should really be a 2 way street. I don't see a reason why the JRuby implementation cant take the lead on fixing some things ahead of the CRuby impl and have the CRuby impl come up to where they JRuby version is. |
@rdingwell I know your frustration. I'm the one who have fought over the same frustration for a long time. However, it is important for pure Java Nokogiri. I'll have a look to find a way to make those feature work using your namespace fix. So, please be patient for a while. |
Sorry to ask, but any updates on this issue? Thanks. |
I have not heard anything for a couple of months. What I wished would happen is that this would get incorporated and then have the discrepancies reported as bugs in the CRuby implementation so they could be addressed there by someone who is familiar with that code and more proficient in C then I am. While one of the issues that this pull request addresses is related to the Java implementation the other 2 are issues are related to both the C and Java implementations and what is allowed in XML spec as far as handling namespaces goes. This fixes those issues for the Java side and they should also be addressed on the C side of things. I think to some degree the Java side of nokogiri is still a second class citizen as issues do not appear to be able to be addressed in the Java side before they are in the C side but the other way around is expected. In some ways I understand it as nokogiri started out as a C impl and then the java version came later but why isnt anyone working on the C side of things to address the namespace issues that are reported. |
I appreciate the work here, but I'm not comfortable introducing different behavior into JRuby that's not there for other versions of Ruby. I'll dig into what's needed to make this work in the CRuby version. |
Thanks for the rework. However, the logic in the pull request has a flaw and breaks more tests. I'm going to close this pull request. |
THe problem with your approach is that it does not allow for prefixes to be redefined at different levels in the tree. This is something that is allowed in the XML spec and is another thing that I had implemented. I understand the need to try and keep things in sync but I think my previous comments pretty much outline my feelings on this subject. Those tests that you refer to as being broken were not broken but simply additional functionality that I had been arguing should have been implemented in the CRuby impl as well. Either way I'm done with this. |
I realize that this is a fairly large pull request but I believe that it address some issues on the Java side of Nokogiri. The main thrust of the work is a reworking of the NamespaceCache to cache namespaces based on the node from which they are declared. The caching itself is still performed in a central object but it has been reworked to store the namespaces in a hierarchal manor. This allows for a namespace prefixes and default namespaces to be redeclared on elements as allowed for by the xml specification. This pull request also address issues #902 #940 and #943.
All of the tests pass though 2 of them needed to be skipped do to allowing namespace redefinition. The 2 tests that were skipped are in the test_builder.rb file and are specifically related to testing that you cannot redefine namespaces.