Module: Xml::XmlCanonical
- Defined in:
- lib/r4x/e4x.rb
Overview
This is used it identify strings that conform to canonical XML element text.
Class Method Summary collapse
Class Method Details
.===(str) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/r4x/e4x.rb', line 32 def ===( str ) str = str.to_s.strip #str[0,1] == '<' && str[-1,1] == '>' # should make more robust (TODO) md = (%r{\A \< (\w+) (.*?) \>}mix).match( str ) return false unless md #[2] =~ %r{xml:cdata=['"]\d+['"]} ed = (%r{\< \/ #{md[1]} [ ]* \> \Z}mix).match(str) return false unless ed true end |