Skip to main content

xml

Function xml 

Source
pub fn xml(parser: &mut Tabnas, options: &XmlOptions) -> Result<(), PluginError>
Expand description

Install the XML grammar on parser, which should already carry the jsonic grammar (as make arranges): the port of the Xml plugin function.

In pure mode the parser is reconfigured for XML alone: xml becomes the start rule, the JSON structural tokens and every non-XML lexer are switched off, and jsonic’s value rules are removed. In embed mode the jsonic grammar stays and XML elements become values. Installation is idempotent: an instance that already carries the xml rule is left alone.

let mut parser = tabnas_jsonic::make();
tabnas_xml::xml(&mut parser, &tabnas_xml::XmlOptions::default())?;
assert_eq!(
    parser.parse("<a x='1'/>")?.to_string(),
    r#"{"name":"a","localName":"a","attributes":{"x":"1"},"children":[]}"#
);