Module: Moxml::C14n
- Defined in:
- lib/moxml/c14n.rb,
lib/moxml/c14n/node.rb,
lib/moxml/c14n/nodes.rb,
lib/moxml/c14n/writer.rb,
lib/moxml/c14n/exclusive.rb,
lib/moxml/c14n/processor.rb,
lib/moxml/c14n/data_model.rb,
lib/moxml/c14n/inclusive_10.rb,
lib/moxml/c14n/inclusive_11.rb,
lib/moxml/c14n/nodes/root_node.rb,
lib/moxml/c14n/nodes/text_node.rb,
lib/moxml/c14n/xml_base_handler.rb,
lib/moxml/c14n/attribute_handler.rb,
lib/moxml/c14n/character_encoder.rb,
lib/moxml/c14n/namespace_context.rb,
lib/moxml/c14n/namespace_handler.rb,
lib/moxml/c14n/nodes/comment_node.rb,
lib/moxml/c14n/nodes/element_node.rb,
lib/moxml/c14n/nodes/attribute_node.rb,
lib/moxml/c14n/nodes/namespace_node.rb,
lib/moxml/c14n/nodes/processing_instruction_node.rb
Overview
Canonicalization engine. Core moxml feature — sibling to Moxml::XPath, Moxml::Builder, Moxml::SAX.
Inclusive C14N (1.0 and 1.1) is ported from canon (lutaml/canon): mature, tested, full-featured (xml:base fixup, inheritable xml:* attribute resolution, node-set subset canonicalization).
Exclusive C14N (1.0) is a moxml-native implementation; canon does not implement exclusive. It is required by XML signature to keep signatures valid when subdocuments are moved between contexts.
Defined Under Namespace
Modules: Nodes Classes: AttributeHandler, CharacterEncoder, DataModel, Exclusive, Inclusive10, Inclusive11, NamespaceContext, NamespaceHandler, Node, Processor, Writer, XmlBaseHandler
Constant Summary collapse
- XMLNS_URI =
"http://www.w3.org/2000/xmlns/"- XML_URI =
"http://www.w3.org/XML/1998/namespace"
Class Method Summary collapse
-
.canonicalize(node_or_xml, with_comments: false, algorithm: :inclusive10, inclusive_namespaces: []) ⇒ Object
Canonicalize using the named algorithm.
- .canonicalize_exclusive(node_or_xml, with_comments: false, inclusive_namespaces: []) ⇒ Object
- .canonicalize_inclusive10(node_or_xml, with_comments: false) ⇒ Object
- .canonicalize_inclusive11(node_or_xml, with_comments: false) ⇒ Object
-
.equivalent?(left, right, with_comments: false, algorithm: :inclusive10, inclusive_namespaces: []) ⇒ Boolean
Compare two XML inputs by their canonical forms.
- .escape_attribute(value) ⇒ Object
- .escape_text(text) ⇒ Object
Class Method Details
.canonicalize(node_or_xml, with_comments: false, algorithm: :inclusive10, inclusive_namespaces: []) ⇒ Object
Canonicalize using the named algorithm.
algorithm is one of:
:inclusive10 Canonical XML 1.0 (default; W3C REC-xml-c14n-20010315)
:inclusive11 Canonical XML 1.1 (W3C REC-xml-c14n11-20080502)
:exclusive10 Exclusive C14N 1.0 (W3C REC-xml-exc-c14n-20020718)
40 41 42 43 44 45 46 47 |
# File 'lib/moxml/c14n.rb', line 40 def self.canonicalize(node_or_xml, with_comments: false, algorithm: :inclusive10, inclusive_namespaces: []) engine_for(algorithm).canonicalize( node_or_xml, with_comments: with_comments, inclusive_namespaces: inclusive_namespaces, ) end |
.canonicalize_exclusive(node_or_xml, with_comments: false, inclusive_namespaces: []) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/moxml/c14n.rb', line 57 def self.canonicalize_exclusive(node_or_xml, with_comments: false, inclusive_namespaces: []) Exclusive.new.canonicalize( node_or_xml, with_comments: with_comments, inclusive_namespaces: inclusive_namespaces, ) end |
.canonicalize_inclusive10(node_or_xml, with_comments: false) ⇒ Object
49 50 51 |
# File 'lib/moxml/c14n.rb', line 49 def self.canonicalize_inclusive10(node_or_xml, with_comments: false) Inclusive10.new.canonicalize(node_or_xml, with_comments: with_comments) end |
.canonicalize_inclusive11(node_or_xml, with_comments: false) ⇒ Object
53 54 55 |
# File 'lib/moxml/c14n.rb', line 53 def self.canonicalize_inclusive11(node_or_xml, with_comments: false) Inclusive11.new.canonicalize(node_or_xml, with_comments: with_comments) end |
.equivalent?(left, right, with_comments: false, algorithm: :inclusive10, inclusive_namespaces: []) ⇒ Boolean
Compare two XML inputs by their canonical forms.
67 68 69 70 71 72 73 |
# File 'lib/moxml/c14n.rb', line 67 def self.equivalent?(left, right, with_comments: false, algorithm: :inclusive10, inclusive_namespaces: []) canonicalize(left, with_comments: with_comments, algorithm: algorithm, inclusive_namespaces: inclusive_namespaces) == canonicalize(right, with_comments: with_comments, algorithm: algorithm, inclusive_namespaces: inclusive_namespaces) end |
.escape_attribute(value) ⇒ Object
79 80 81 |
# File 'lib/moxml/c14n.rb', line 79 def self.escape_attribute(value) CharacterEncoder.new.encode_attribute(value) end |
.escape_text(text) ⇒ Object
75 76 77 |
# File 'lib/moxml/c14n.rb', line 75 def self.escape_text(text) CharacterEncoder.new.encode_text(text) end |