Sha256: e59348f2a3b302587615f68d97fde356cd62c8d9bf63e93b38476577a5eed4f5

Contents?: true

Size: 1.15 KB

Versions: 22

Compression:

Stored size: 1.15 KB

Contents

module LibXML
  module XML
    class Namespaces
      # call-seq:
      #   namespace.default -> XML::Namespace
      #
      # Returns the default namespace for this node or nil.
      #
      # Usage:
      #   doc = XML::Document.string('<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"/>')
      #   ns = doc.root.namespaces.default_namespace
      #   assert_equal(ns.href, 'http://schemas.xmlsoap.org/soap/envelope/')
      def default
        find_by_prefix(nil)
      end

      # call-seq:
      #   namespace.default_prefix = "string"
      #
      # Assigns a name (prefix) to the default namespace.
      # This makes it much easier to perform XML::XPath
      # searches.
      #
      # Usage:
      #   doc = XML::Document.string('<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"/>')
      #   doc.root.namespaces.default_prefix = 'soap'
      #   node = doc.root.find_first('soap:Envelope')
      def default_prefix=(prefix)
        # Find default prefix
        ns = find_by_prefix(nil)
        raise(ArgumentError, "No default namespace was found") unless ns
        Namespace.new(self.node, prefix, ns.href)
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
libxml-ruby-r19mingw-1.1.4 lib/libxml/namespaces.rb
libxml-ruby-1.1.4 lib/libxml/namespaces.rb
libxml-ruby-1.1.4-x86-mswin32-60 lib/libxml/namespaces.rb
coupa-libxml-ruby-1.1.4 lib/libxml/namespaces.rb
libxml-ruby-0.9.6-x86-mswin32-60 lib/libxml/namespaces.rb
libxml-ruby-0.9.6 lib/libxml/namespaces.rb
libxml-ruby-0.9.7-x86-mswin32-60 lib/libxml/namespaces.rb
libxml-ruby-0.9.7 lib/libxml/namespaces.rb
libxml-ruby-0.9.9-x86-mswin32-60 lib/libxml/namespaces.rb
libxml-ruby-1.0.0 lib/libxml/namespaces.rb
libxml-ruby-1.0.0-x86-mswin32-60 lib/libxml/namespaces.rb
libxml-ruby-1.1.0 lib/libxml/namespaces.rb
libxml-ruby-1.1.0-x86-mswin32-60 lib/libxml/namespaces.rb
libxml-ruby-0.9.8-x86-mswin32-60 lib/libxml/namespaces.rb
libxml-ruby-0.9.9 lib/libxml/namespaces.rb
libxml-ruby-0.9.8 lib/libxml/namespaces.rb
libxml-ruby-1.1.2-x86-mswin32-60 lib/libxml/namespaces.rb
libxml-ruby-1.1.3 lib/libxml/namespaces.rb
libxml-ruby-1.1.1 lib/libxml/namespaces.rb
libxml-ruby-1.1.1-x86-mswin32-60 lib/libxml/namespaces.rb