Skip to main content

Module decode

Module decode 

Source
Expand description

Turning a document into data.

Validation already produces a typed PSVI — every element with the type in force, every value parsed into its value space. What it does not produce is a shape: reconstructing a nested value out of StartElement/Text/EndElement is work every consumer would otherwise redo, and redo differently.

Decoded is that shape, and it is lossless: qualified names, the type in force after any xsi:type, xsi:nil, and which values the schema supplied rather than the document. The Python bindings project it onto dictionaries, which is lossy on purpose; this is the layer that is not.

use xsdkit::Schemas;

fn read(schemas: &Schemas, xml: &str) -> Option<()> {
    let doc = schemas.decode(xml).into_result().ok()?;
    for child in doc.children() {
        println!("{}", schemas.display_psvi_name(&child.name));
    }
    Some(())
}

Structs§

Decoded
One element of a decoded document.
DecodedAttribute
One attribute, with its value in the value space of its type.
Decoding
What decoding produced: the tree, and every diagnostic raised on the way.

Enums§

DecodedContent
What an element contains.