normalize( input, doctype=nil, entity_filter=nil )private
Escapes all possible entities
# File lib/rexml/text.rb, line 372
def Text::normalize( input, doctype=nil, entity_filter=nil )
copy = input.to_s
# Doing it like this rather than in a loop improves the speed
#copy = copy.gsub( EREFERENCE, '&' )
copy = copy.gsub( "&", "&" )
if doctype
# Replace all ampersands that aren't part of an entity
doctype.entities.each_value do |entity|
copy = copy.gsub( entity.value,
"&#{entity.name};" ) if entity.value and
not( entity_filter and entity_filter.include?(entity.name) )
end
else
# Replace all ampersands that aren't part of an entity
DocType::DEFAULT_ENTITIES.each_value do |entity|
copy = copy.gsub(entity.value, "&#{entity.name};" )
end
end
copy
end Related methods
- Instance methods
- <<
- <=>
- clone
- doctype
- empty?
- indent_text
- inspect
- node_type
- parent=
- to_s
- value
- value=
- wrap
- write
- write_with_substitution
- xpath
- Class methods
- check
- new
- Private methods
-
expand -
normalize -
read_with_substitution -
unnormalize -
clear_cache