diagram_core/src/formula/xml.rs#
Source: lib/diagram_core/src/formula/xml.rs
xml -- a small element tree of a theme part (DrawingML with Visio's extensions)
Theme parts are a few dozen kilobytes of attributes; the engine reads colours, fonts and
style lists from them. The reading is formats::xml::Lenient's (nothing is an error: a broken
tag or reference is read as far as it goes); this tree keeps elements (local names, attributes
without the xmlns declarations, children) and drops text, comments, processing instructions and
the DOCTYPE; an end tag closes the element open last. Limits: 200 000 elements, depth 256; a
second root element or a limit ends the tree there.
struct Elemone element: its local name (prefix removed), attributes (local names) and childrenname: String-- the name without prefixattrs: Vec<(String, String)>-- the attributes without prefixes, values with entities decodedchildren: Vec<u32>-- the children (indices into Tree::elems)
struct Treea parsed partelems: Vec<Elem>-- all elements; 0 is the root when the part had one
impl Tree
fn parse(data: &[u8]) -> Treeread a part (UTF-8; a BOM is skipped)fn get(&self, i: u32) -> Option<&Elem>an elementfn child(&self, i: u32, name: &str) -> Option<u32>the first child ofinamednamefn children<'a>(&'a self, i: u32, name: &'a str) -> impl Iterator<Item = u32> + 'athe children ofinamednamefn path(&self, i: u32, names: &[&str]) -> Option<u32>the element at a path of names belowi(each step the first match)fn find(&self, i: u32, name: &str) -> Option<u32>the first element namednameanywhere belowi(depth first)fn attr(&self, i: u32, name: &str) -> Option<&str>an attribute ofi