Module REXML::Namespace
In: lib/rexml/namespace.rb

Adds named attributes to an object.

Methods

Included Modules

XMLTokens

Constants

NAMESPLIT = /^(?:(#{NCNAME_STR}):)?(#{NCNAME_STR})/u

External Aliases

name -> local_name

Attributes

expanded_name  [R]  The name of the object, valid if set
name  [R]  The name of the object, valid if set
prefix  [RW]  The expanded name of the object, valid if name is set

Public Instance methods

Fully expand the name, even if the prefix wasn‘t specified in the source file.

[Source]

    # File lib/rexml/namespace.rb, line 41
41:                 def fully_expanded_name
42:                         ns = prefix
43:                         return "#{ns}:#@name" if ns.size > 0 
44:                         return @name
45:                 end

Compares names optionally WITH namespaces

[Source]

    # File lib/rexml/namespace.rb, line 27
27:                 def has_name?( other, ns=nil )
28:                         if ns
29:                                 return (namespace() == ns and name() == other)
30:                         elsif other.include? ":"
31:                                 return fully_expanded_name == other
32:                         else
33:                                 return name == other
34:                         end
35:                 end

Sets the name and the expanded name

[Source]

    # File lib/rexml/namespace.rb, line 14
14:                 def name=( name )
15:                         @expanded_name = name
16:                         name =~ NAMESPLIT
17:                         if $1
18:                                 @prefix = $1
19:                         else
20:                                 @prefix = ""
21:                                 @namespace = ""
22:                         end
23:                         @name = $2
24:                 end

[Validate]