Use namespace_name in Attribute#to_xml
Instead of using `namespace.name` lets just use `namespace_name`. This fixes the problem of serializing attributes where the namespace prefix is "xmlns" as the namespace for this isn't registered by default. This fixes #47.
This commit is contained in:
parent
00579eaa8a
commit
75f4e81533
|
@ -82,7 +82,7 @@ module Oga
|
||||||
#
|
#
|
||||||
def to_xml
|
def to_xml
|
||||||
if namespace_name
|
if namespace_name
|
||||||
full_name = "#{namespace.name}:#{name}"
|
full_name = "#{namespace_name}:#{name}"
|
||||||
else
|
else
|
||||||
full_name = name
|
full_name = name
|
||||||
end
|
end
|
||||||
|
|
|
@ -68,6 +68,16 @@ describe Oga::XML::Attribute do
|
||||||
|
|
||||||
attr.to_xml.should == 'foo:class="10"'
|
attr.to_xml.should == 'foo:class="10"'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
example 'include the "xmlns" namespace when present but not registered' do
|
||||||
|
attr = described_class.new(
|
||||||
|
:name => 'class',
|
||||||
|
:namespace_name => 'xmlns',
|
||||||
|
:element => Oga::XML::Element.new
|
||||||
|
)
|
||||||
|
|
||||||
|
attr.to_xml.should == 'xmlns:class=""'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context '#inspect' do
|
context '#inspect' do
|
||||||
|
|
Loading…
Reference in New Issue