Class REXML::Text
In: lib/xmpp4r/rexmladdons.rb
Parent: Object
XMLTokens XPathParser Text IOSource Attribute Element lib/xmpp4r/rexmladdons.rb REXML dot/m_64_0.png

Methods

normalize  

Public Class methods

Escapes all possible entities

[Source]

     # File lib/xmpp4r/rexmladdons.rb, line 841
841:     def Text::normalize( input, doctype=nil, entity_filter=nil )
842:       copy = input
843:       # Doing it like this rather than in a loop improves the speed
844:       if doctype
845:         # Replace all ampersands that aren't part of an entity
846:         copy = copy.gsub( EREFERENCE, '&' )
847:         doctype.entities.each_value do |entity|
848:           copy = copy.gsub( entity.value, 
849:             "&#{entity.name};" ) if entity.value and 
850:               not( entity_filter and entity_filter.include?(entity) )
851:         end
852:       else
853:         # Replace all ampersands
854:         copy = copy.gsub( '&', '&' )
855:         DocType::DEFAULT_ENTITIES.each_value do |entity|
856:           copy = copy.gsub(entity.value, "&#{entity.name};" )
857:         end
858:       end
859:       copy
860:     end

[Validate]