Skip to main content

decode_general_ref

Function decode_general_ref 

Source
pub fn decode_general_ref(reference: &BytesRef<'_>) -> Result<Option<String>>
Expand description

Resolves a &entity;/&#NNN; general reference (quick_xml::events::Event::GeneralRef, BytesRef) found in text content to the character(s) it represents — see decode_text’s doc comment for why this is a separate event from Text in quick_xml 0.41, and therefore a separate, necessary step, not an edge case.

Handles the two kinds of reference this toolkit’s own Writer (and any real Word-authored document) can produce: a numeric character reference (&#65;/&#x41;, resolved via quick_xml::events::BytesRef::resolve_char_ref) and the five predefined XML entities (&amp;/&lt;/&gt;/&apos;/ &quot;, resolved via quick_xml::escape::resolve_xml_entity). Returns Ok(None) for anything else (a custom, DTD-declared entity — this crate has no DTD support to resolve one) — callers drop it rather than failing the whole document, the same forgiving policy applied to other malformed/unsupported constructs throughout this toolkit’s readers.