Skip to main content

Crate xml_core

Crate xml_core 

Source
Expand description

xml-core — low-level XML infrastructure for the toolkit.

This crate provides reading and writing of generic XML streams, with no knowledge of the OOXML vocabulary (WordprocessingML, SpreadsheetML, PresentationML, DrawingML). It builds on quick-xml for low-level parsing/writing; all logic specific to Office (schemas, elements, specific attributes) lives in the higher-level crates (opc, word-ooxml, excel-ooxml, etc.).

Structs§

BytesDecl
Re-exported XML event types from quick-xml, forming the generic XML vocabulary used throughout this crate’s public API (start/end/empty elements, text, comments, etc.). These are not specific to any Office XML vocabulary. An XML declaration (Event::Decl).
BytesEnd
Re-exported XML event types from quick-xml, forming the generic XML vocabulary used throughout this crate’s public API (start/end/empty elements, text, comments, etc.). These are not specific to any Office XML vocabulary. Closing tag data (Event::End): </name>.
BytesRef
Re-exported XML event types from quick-xml, forming the generic XML vocabulary used throughout this crate’s public API (start/end/empty elements, text, comments, etc.). These are not specific to any Office XML vocabulary. Character or general entity reference (Event::GeneralRef): &ref; or &#<number>;.
BytesStart
Re-exported XML event types from quick-xml, forming the generic XML vocabulary used throughout this crate’s public API (start/end/empty elements, text, comments, etc.). These are not specific to any Office XML vocabulary. Opening tag data (Event::Start), with optional attributes: <name attr="value">.
BytesText
Re-exported XML event types from quick-xml, forming the generic XML vocabulary used throughout this crate’s public API (start/end/empty elements, text, comments, etc.). These are not specific to any Office XML vocabulary. Data from various events (most notably, Event::Text).
Reader
Reads a sequence of generic XML events from an in-memory UTF-8 string.
Writer
Writes a sequence of generic XML events to an underlying std::io::Write.

Enums§

Error
Errors that can occur while reading or writing XML with xml-core.
Event
Re-exported XML event types from quick-xml, forming the generic XML vocabulary used throughout this crate’s public API (start/end/empty elements, text, comments, etc.). These are not specific to any Office XML vocabulary. Event emitted by Reader::read_event_into.

Functions§

decode_attribute_value
Decodes an XML attribute’s raw value, undoing XML entity escaping — mirrors decode_text for attribute values. quick_xml’s own Attribute::from((&str, &str)) (used throughout this toolkit’s writers via BytesStart::push_attribute) escapes the value the exact same way BytesText::new does, so this is needed for the same reason.
decode_general_ref
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.
decode_text
Decodes an XML text event’s content: character-encoding decoding (e.g. UTF-16 to UTF-8) via quick_xml::events::BytesText::decode, plus a defensive unescape() pass in case any literal &...; survived in the event’s own bytes (see below for why that’s normally not needed).

Type Aliases§

Result
A Result alias using [Error] as the error type.