Permalink
Browse files

Fix for an element without a namespace nested inside of one with a na…

…mespace

Set the namespace to false for elements that do not share the same namespace as the class:

  class Alert
    include HappyMapper
    namespace 'http://example.com/ns/alert'

    element :severity, String, :namespace => false
  end
  • Loading branch information...
1 parent c5c96d0 commit f42adb6e2c79619c457cee8451e9b017a85b86c9 @bkeepers bkeepers committed Oct 2, 2009
Showing with 6 additions and 4 deletions.
  1. +6 −4 lib/happymapper/item.rb
@@ -128,14 +128,16 @@ def constantize(type)
end
def find(node, namespace, &block)
- # this node has a custom namespace (that is present in the doc)
- if self.namespace
- namespace = "#{DEFAULT_NS}:#{self.namespace}"
+ if options[:namespace] == false
+ namespace = nil
elsif options[:namespace]
# from an element definition
namespace = "#{DEFAULT_NS}:#{options[:namespace]}"
+ elsif self.namespace
+ # this node has a custom namespace (that is present in the doc)
+ namespace = "#{DEFAULT_NS}:#{self.namespace}"
end
-
+
if element?
if(options[:single].nil? || options[:single])
result = node.find_first(xpath(namespace), namespace)

0 comments on commit f42adb6

Please sign in to comment.