Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/rdf/xsd/extensions.rb
Overview
REXML C14N
Instance Method Summary collapse
-
#c14nxl(options = {}) ⇒ Object
Canonicalize the NodeSet.
-
#to_s_with_c14nxl ⇒ Object
(also: #to_s)
Serialize a canonicalized Node or NodeSet to XML.
Instance Method Details
#c14nxl(options = {}) ⇒ Object
Canonicalize the NodeSet. Return a new NodeSet marked as being canonical with all child nodes canonicalized.
136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/rdf/xsd/extensions.rb', line 136 def c14nxl( = {}) # Create a new NodeSet set = [] set.instance_variable_set(:@c14nxl, true) # Unless passed a set of namespaces, figure them out from namespace_scopes #options[:namespaces] ||= first.parent.namespace_scopes.compact.inject({}) do |memo, ns| # memo[ns.prefix] = ns.href.to_s # memo #end self.each {|c| set << (c.respond_to?(:c14nxl) ? c.c14nxl() : c)} set end |
#to_s_with_c14nxl ⇒ Object Also known as: to_s
Serialize a canonicalized Node or NodeSet to XML
Override standard #to_s implementation to output in c14n representation if the Node or NodeSet is marked as having been canonicalized
156 157 158 159 160 161 162 |
# File 'lib/rdf/xsd/extensions.rb', line 156 def to_s_with_c14nxl if instance_variable_defined?(:@c14nxl) map {|c| c.to_s}.join("") else to_s_without_c14nxl end end |