diff --git a/lib/oga/xml/parser.y b/lib/oga/xml/parser.y index f7de1c7..9e12bc1 100644 --- a/lib/oga/xml/parser.y +++ b/lib/oga/xml/parser.y @@ -338,8 +338,12 @@ Unexpected #{name} with value #{value.inspect} on line #{@line}: # @return [Oga::XML::Element] # def on_element(namespace, name, attributes = {}) + if namespace + namespace = Namespace.new(:name => namespace) + end + element = Element.new( - :namespace => Namespace.new(:name => namespace), + :namespace => namespace, :name => name, :attributes => attributes ) diff --git a/spec/oga/xml/parser/elements_spec.rb b/spec/oga/xml/parser/elements_spec.rb index 61c5285..10fc35a 100644 --- a/spec/oga/xml/parser/elements_spec.rb +++ b/spec/oga/xml/parser/elements_spec.rb @@ -13,6 +13,10 @@ describe Oga::XML::Parser do example 'set the name of the element' do @element.name.should == 'p' end + + example 'do not set a namespace' do + @element.namespace.nil?.should == true + end end context 'elements with namespaces' do