JFLib

diagram_io/src/xml.rs#

Source: lib/diagram_io/src/xml.rs

xml -- the XML parts of the VSDX family: formats::xml's strict pull reader with the namespaces it knows

  Reader::new(text, depth, attrs)    a part's text (UTF-8 or UTF-16 decoded by text_of)
  r.next() -> Event                  Start, End, Text, Eof; an empty element <a/> gives Start
                                     (empty: true) and then End
  r.skip(&start) -> &str             the rest of an element, returned as the file wrote it
                                     (an unknown element kept for DF-03)

The reader is formats::xml::Reader (strict: well-formed XML 1.0 with namespaces; mixed content,
which shape text is: <Text>ab<cp IX='0'/>cd</Text>; positions for the raw text of unknown
elements).  This file maps its namespace URIs to the few the VSDX reader knows (Ns), its errors to
XmlError, and skips comments and processing instructions; CDATA is text.  Refused, as there: a
DOCTYPE (no entities, no external anything), an undefined entity, a character XML does not allow,
an encoding other than UTF-8 / UTF-16 in the declaration, mismatched or unclosed tags, an unbound
prefix, a duplicate attribute, more nesting than `depth` and more attributes on one element than
`attrs`.  Nothing recurses.
  • enum XmlError what is wrong with a part's XML
    • Syntax -- not well-formed: a broken tag, attribute, entity or character, tags that do not match, text outside the root element, an unbound namespace prefix, a duplicate attribute
    • Depth -- deeper nesting than Limits::depth
    • Attributes -- more attributes on one element than Limits::attrs, or more than 64 namespace declarations in scope
    • Unsupported -- a DOCTYPE, or an encoding other than UTF-8 and UTF-16 (declared or as bytes)

Source: docs/API.md in the JFLib repository.