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

Add a namespaced attribute #252

Closed
superfeedr opened this issue Apr 8, 2010 · 5 comments
Closed

Add a namespaced attribute #252

superfeedr opened this issue Apr 8, 2010 · 5 comments

Comments

@superfeedr
Copy link

Attributes can be of a different namespace than the node they belong too. I wasn't able to find a method to add namespaced attributes, and adding an namespace to an existing attribute

@current.attributes[a.localname].add_namespace(a.prefix, a.uri)

raises an error :
::Attr:0x80b79e4c name="width" value="75">
./parser.rb:65: [BUG] Segmentation fault
ruby 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0]

Abort trap
@flavorjones
Copy link
Member

Here is a reproducible test case (though you should have submitted one yourself if this is of such high importance to you):

doc = Nokogiri::XML "<root xmlns='http://google.com/'> <a myattr='blah'></a></root>"
node = doc.at_css "a"
attr = node.attributes['myattr']
attr.add_namespace("fizzle", "http://fizzle.com/")

@superfeedr
Copy link
Author

Sorry about this... yes, you're right, I should have submitted this myself :(

@flavorjones
Copy link
Member

OK, it looks like libxml2 treats namespaces on properties differently enough than namespaces on elements that this is going to be an involved change. Most likely this will not be in 1.4.2. Targetting for 1.5.0.

@superfeedr
Copy link
Author

Ok, thanks for the quick note on this. I'll write a note soon on what we think is good for the namespace manegement in Nokogiri. I'll email to you/Aaron!

Again, thanks.

@flavorjones
Copy link
Member

Attr#add_namespace now works as expected. Closed by 34a1424.

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

No branches or pull requests

1 participant