Skip to main content

normalize_attribute_value

Function normalize_attribute_value 

Source
pub fn normalize_attribute_value<'input, 'entity, C, E, F>(
    value: &'input str,
    depth: usize,
    is_normalization_char: C,
    normalize_eol_step: E,
    resolve_entity: F,
) -> Result<Cow<'input, str>, EscapeError>
where C: Fn(&u8) -> bool, E: Fn(&mut String, &str, usize, char) -> usize, F: FnMut(&str) -> Option<&'entity str>,
Expand description

Returns the attribute value normalized as per the XML specification, using a custom entity resolver.

Do not use this method with HTML attributes.

Escape sequences such as &gt; are replaced with their unescaped equivalents, and the characters \t, \r, \n are replaced with a space. This allocates unless the raw attribute value does not require normalization.

ยงParameters

  • value: the unnormalized attribute value;
  • depth: maximum number of nested entities that can be expanded before EscapeError::TooManyNestedEntities is returned;
  • is_normalization_char: predicate reporting whether a byte begins a character requiring normalization (UTF-8 encoding assumed);
  • normalize_eol_step: a function performing EOL normalization of a character;
  • resolve_entity: a function to resolve named entities.