Class: REXML::Element
- Inherits:
-
Object
- Object
- REXML::Element
- Defined in:
- lib/reddy/rexml_hacks.rb
Overview
def subdocument_writer(el)
el.prefixes.each { |ns|
el.add_attribute('xmlns:' + ns, el.namespaces[ns].to_s)
}
return el.to_s
end
Instance Method Summary collapse
-
#base ⇒ String
Tells you what the set xml:lang is for an element.
-
#base? ⇒ Boolean
Tells you whether or not an element has a set xml:base.
-
#lang ⇒ String
Tells you what the set xml:lang is for an element.
-
#lang? ⇒ Boolean
Tells you whether or not an element has a set xml:lang.
-
#write_reddy(excl = []) ⇒ String
Allows you to write out an XML representation of a particular element and it’s children, fixing namespace issues.
Instance Method Details
#base ⇒ String
Tells you what the set xml:lang is for an element.
Returns
58 59 60 61 62 63 64 65 66 |
# File 'lib/reddy/rexml_hacks.rb', line 58 def base if self.attributes['xml:base'] return self.attributes['xml:base'].to_s elsif self.parent != nil return self.parent.base else return nil end end |
#base? ⇒ Boolean
Tells you whether or not an element has a set xml:base.
43 44 45 46 47 48 49 |
# File 'lib/reddy/rexml_hacks.rb', line 43 def base? if self.base != nil true else false end end |
#lang ⇒ String
Tells you what the set xml:lang is for an element.
Returns
29 30 31 32 33 34 35 36 37 |
# File 'lib/reddy/rexml_hacks.rb', line 29 def lang if self.attributes['xml:lang'] return self.attributes['xml:lang'].to_s elsif self.parent != nil return self.parent.lang else return nil end end |
#lang? ⇒ Boolean
Tells you whether or not an element has a set xml:lang.
18 19 20 |
# File 'lib/reddy/rexml_hacks.rb', line 18 def lang? self.lang.nil? ? false : true end |
#write_reddy(excl = []) ⇒ String
Allows you to write out an XML representation of a particular element and it’s children, fixing namespace issues.
Returns
75 76 77 78 79 80 81 82 |
# File 'lib/reddy/rexml_hacks.rb', line 75 def write_reddy(excl=[]) # TODO: add optional list argument of excluded namespaces self.prefixes.each { |ns| self.add_attribute('xmlns:' + ns, self.namespaces[ns].to_s) unless excl.include? self.namespaces[ns] } self.support_write_recursive(self.namespaces, self) return self.to_s end |