module Saml::XMLUtil

Overview

XML helpers shared by every SAML message.

Defined in:

saml/xml_util.cr

Constant Summary

PARSER_OPTIONS = XML::ParserOptions::NONET

No RECOVER: libxml2 must refuse anything that isn't well-formed rather than repair it.

Class Method Summary

Class Method Detail

def self.add_child(parent : XML::Node, node : XML::Node) : XML::Node #

Moves node (already in the same document) to the end of parent.


[View source]
def self.add_element(parent : XML::Node, name : String, attributes = nil) : XML::Node #

Adds an element under parent in the same document. Names and attributes may be prefixed; "xmlns"/"xmlns:p" entries declare namespaces.


[View source]
def self.add_next_sibling(sibling : XML::Node, node : XML::Node) : XML::Node #

Moves node (already in the same document) right after sibling.


[View source]
def self.add_prev_sibling(sibling : XML::Node, node : XML::Node) : XML::Node #

Moves node (already in the same document) right before sibling.


[View source]
def self.element_children(node : XML::Node) : Array(XML::Node) #

Element children only, in document order.


[View source]
def self.element_text(element : XML::Node | Nil) : String | Nil #

Concatenates the element's own text and CDATA children only, so comments and child elements can't change or truncate the value.


[View source]
def self.escape_attribute(value : String) : String #

[View source]
def self.only_node(node, path : String, namespaces = nil, variables = nil) : XML::Node | Nil #

Exactly one match or nil.


[View source]
def self.safe_parse(xml : String) : XML::Node #

Parses untrusted XML: well-formed only, no DOCTYPE, no network, and no errors or warnings at all (namespace errors don't stop libxml2 by themselves).


[View source]
def self.set_attribute(node : XML::Node, name : String, value : String) : Nil #

[View source]