From f2d69af33b846cf9acaec6959cff29308fab14b9 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 26 Mar 2015 00:43:50 +0100 Subject: [PATCH] Distinguish default attribute/element namespaces The previous commit messed this up because I wasn't fully awake. --- lib/oga/xml/attribute.rb | 11 +++++++++++ lib/oga/xml/default_namespace.rb | 2 +- spec/oga/xml/attribute_spec.rb | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/oga/xml/attribute.rb b/lib/oga/xml/attribute.rb index 9a227de..07c3666 100644 --- a/lib/oga/xml/attribute.rb +++ b/lib/oga/xml/attribute.rb @@ -21,6 +21,17 @@ module Oga class Attribute attr_accessor :name, :namespace_name, :element, :value + ## + # The default namespace available to all attributes. This namespace can + # not be modified. + # + # @return [Oga::XML::Namespace] + # + DEFAULT_NAMESPACE = Namespace.new( + :name => 'xml', + :uri => XML::DEFAULT_NAMESPACE.uri + ).freeze + ## # @param [Hash] options # diff --git a/lib/oga/xml/default_namespace.rb b/lib/oga/xml/default_namespace.rb index fab44b4..b486766 100644 --- a/lib/oga/xml/default_namespace.rb +++ b/lib/oga/xml/default_namespace.rb @@ -6,7 +6,7 @@ module Oga # @return [Oga::XML::Namespace] # DEFAULT_NAMESPACE = Namespace.new( - :name => 'xml', + :name => 'xmlns', :uri => 'http://www.w3.org/XML/1998/namespace' ).freeze end # XML diff --git a/spec/oga/xml/attribute_spec.rb b/spec/oga/xml/attribute_spec.rb index 0afc4b5..686e1bf 100644 --- a/spec/oga/xml/attribute_spec.rb +++ b/spec/oga/xml/attribute_spec.rb @@ -33,7 +33,7 @@ describe Oga::XML::Attribute do end it 'returns the default XML namespace when the "xml" prefix is used' do - @default.namespace.should == Oga::XML::DEFAULT_NAMESPACE + @default.namespace.should == Oga::XML::Attribute::DEFAULT_NAMESPACE end end