Sha256: 97c764d5379caeea97e7dc1a40e881c2018afefa98007b700a6c576a2de060af

Contents?: true

Size: 1.2 KB

Versions: 72

Compression:

Stored size: 1.2 KB

Contents

# encoding: UTF-8

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

72 entries across 72 versions & 1 rubygems

Version Path
libxml-ruby-2.4.0 lib/libxml/namespaces.rb
libxml-ruby-2.3.3-x86-mingw32 lib/libxml/namespaces.rb
libxml-ruby-2.3.3 lib/libxml/namespaces.rb
libxml-ruby-2.3.2 lib/libxml/namespaces.rb
libxml-ruby-2.3.0-x86-mingw32 lib/libxml/namespaces.rb
libxml-ruby-2.3.0 lib/libxml/namespaces.rb
libxml-ruby-2.2.2-x86-mingw32 lib/libxml/namespaces.rb
libxml-ruby-2.2.2 lib/libxml/namespaces.rb
libxml-ruby-2.2.1-x86-mingw32 lib/libxml/namespaces.rb
libxml-ruby-2.2.1 lib/libxml/namespaces.rb
libxml-ruby-2.2.0-x86-mingw32 lib/libxml/namespaces.rb
libxml-ruby-2.2.0 lib/libxml/namespaces.rb
libxml-ruby-2.1.2-x86-mingw32 lib/libxml/namespaces.rb
libxml-ruby-2.1.2 lib/libxml/namespaces.rb
libxml-ruby-2.1.1-x86-mingw32 lib/libxml/namespaces.rb
libxml-ruby-2.1.1 lib/libxml/namespaces.rb
libxml-ruby-2.1.0-x86-mingw32 lib/libxml/namespaces.rb
libxml-ruby-2.1.0 lib/libxml/namespaces.rb
libxml-ruby-2.0.9-x86-mingw32 lib/libxml/namespaces.rb
libxml-ruby-2.0.9 lib/libxml/namespaces.rb