def _normalizeValue(value, withRefs=False, modFunct=None, titlesRefs=None, namesRefs=None, charactersRefs=None):
 if isinstance(value, (unicode, str)):
  if (not withRefs):
   value = _handleTextNotes(escape4xml(value))
  else:
   replaceLists = _refsToReplace(value, modFunct, titlesRefs, namesRefs, charactersRefs)
   value = modFunct(value, (titlesRefs or {}), (namesRefs or {}), (charactersRefs or {}))
   value = _handleTextNotes(escape4xml(value))
   for replaceList in replaceLists:
    for (toReplace, replaceWith) in replaceList:
     value = value.replace(toReplace, replaceWith)
 else:
  value = unicode(value)
 return value

def _normalizeValue ( value , withRefs = False , modFunct = None , titlesRefs = None , namesRefs = None , charactersRefs = None ) : if isinstance ( value , ( unicode , str ) ) : if ( not withRefs ) : value = _handleTextNotes ( escape4xml ( value ) ) else : replaceLists = _refsToReplace ( value , modFunct , titlesRefs , namesRefs , charactersRefs ) value = modFunct ( value , ( titlesRefs or { } ) , ( namesRefs or { } ) , ( charactersRefs or { } ) ) value = _handleTextNotes ( escape4xml ( value ) ) for replaceList in replaceLists : for ( toReplace , replaceWith ) in replaceList : value = value . replace ( toReplace , replaceWith ) else : value = unicode ( value ) return value
replace some chars that cant be present in a xml text .