| Module | Dsadmin::XMLTools |
| In: |
lib/dsadmin/xml_tools.rb
|
Module providing a few convenience methods for constructing / handling XML data. For use as mixin
Create a simple +REXML::Attribute+ object with the given name and (optional) value
# File lib/dsadmin/xml_tools.rb, line 64
64: def simpleAttr(aName, aValue = nil)
65: requireNotNil(aName)
66:
67: if (aValue)
68: return REXML::Attribute.new(aName, toUTF(aValue.to_s))
69: else
70: return REXML::Attribute.new(aName)
71: end
72: end
Create a simple +REXML::Document+ object, using aBaseDoc as starting point (can be an XML string / Document / …)
Triggers a bug if aBaseDoc couldn‘t be processed
# File lib/dsadmin/xml_tools.rb, line 44
44: def simpleDoc(aBaseDoc = "")
45: assertNothingRaised {
46: return REXML::Document.new(aBaseDoc)
47: }
48: end
Create a simple +REXML::Element+ object with the given name and (optional) value
# File lib/dsadmin/xml_tools.rb, line 52
52: def simpleElem(aName, aValue = nil)
53: requireNotNil(aName)
54:
55: res = REXML::Element.new(aName)
56: res.text = toUTF(aValue.to_s) if aValue
57:
58: return res
59: end