Skip to main content

Module xml

Module xml 

Source
Expand description

XML and XHTML parsing for declarative UI definitions. XML/HTML parsing module for the Azul toolkit.

Provides two parsing paths:

  • parse_xml_string: builds an XmlNode tree (used by domxml_from_str)
  • parse_xml_to_fast_dom_with_css: builds an arena-based FastDom directly from XML tokens (used by parse_xml_to_styled_dom)

Both paths handle HTML5-lite features: void elements, auto-closing tags, XML entity decoding, <style> CSS extraction, and BOM/DOCTYPE stripping.

Data types (XmlNode, XmlError, etc.) live in azul_core::xml; this module provides the parsing implementations.

Modules§

svg
SVG tessellation, rendering, and geometric operations.

Structs§

CompactDomBuilder
Builder for arena-based DOM construction (FastDom). Builds two parallel Vecs (hierarchy + node_data) in a single DFS pass.
ComponentArgument
FFI-safe replacement for (ComponentArgumentName, ComponentArgumentType) tuple.
ComponentArgumentVec
ComponentArgumentVecSlice
C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
ComponentArguments
Holds the list of arguments and whether the component accepts text content. Used by the compile pipeline to generate Rust function signatures.
ComponentCallbackArg
A single argument in a callback signature.
ComponentCallbackArgVec
ComponentCallbackArgVecSlice
C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
ComponentCallbackSignature
Callback signature: return type + argument list.
ComponentDataField
A field in the component’s internal data model.
ComponentDataFieldVec
ComponentDataFieldVecSlice
C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
ComponentDataModel
A named data model (struct definition) for code generation.
ComponentDataModelVec
ComponentDataModelVecSlice
C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
ComponentDef
A component definition — the “class” / “template” of a component. Can come from Rust builtins, compiled widgets, JSON, or user creation in debugger.
ComponentDefVec
ComponentDefVecSlice
C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
ComponentEnumModel
A named enum model for code generation. Stored in ComponentLibrary::enum_models.
ComponentEnumModelVec
ComponentEnumModelVecSlice
C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
ComponentEnumVariant
A single variant in a component enum model.
ComponentEnumVariantVec
ComponentEnumVariantVecSlice
C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
ComponentFieldNamedValue
Named field value: (field_name, value) pair.
ComponentFieldNamedValueVec
ComponentFieldNamedValueVecSlice
C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
ComponentFieldOverride
An override for a single field in a component instance.
ComponentFieldOverrideVec
ComponentFieldOverrideVecSlice
C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
ComponentFieldTypeBox
Heap-allocated box for recursive ComponentFieldType (e.g. Option<String>). Uses raw pointer indirection to break the infinite size.
ComponentFieldValueBox
Heap-allocated box for recursive ComponentFieldValue (e.g. Some(value)). Uses raw pointer indirection to break the infinite size.
ComponentFieldValueVec
ComponentFieldValueVecSlice
C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
ComponentId
Identifies a component within a library collection. e.g. collection=“builtin”, name=“div” for the <div> element, or collection=“shadcn”, name=“avatar” for a custom component.
ComponentInstanceDefault
Default component instance for a StyledDom slot.
ComponentLibrary
A named collection of component definitions
ComponentLibraryVec
ComponentLibraryVecSlice
C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
ComponentMap
The component map — holds libraries with namespaced components.
CssMatcher
DomXml
Wrapper for the XML parser - necessary to easily create a Dom from XML without putting an XML solver into azul-core.
DuplicatedAttributeError
DuplicatedNamespaceError
ExternalResource
An external resource URL found in an XML/HTML document
ExternalResourceVec
ExternalResourceVecSlice
C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
InvalidCharError
InvalidCharMultipleError
InvalidQuoteError
InvalidSpaceError
InvalidStringError
MalformedHierarchyError
Error for mismatched open/close tags in XML hierarchy
MimeTypeHint
MIME type hint for an external resource
MissingTypeError
Wrapper for MissingType error data.
NonXmlCharError
RegisterComponentFn
Callback struct for registering individual components at startup.
RegisterComponentLibraryFn
Callback struct for registering entire component libraries at startup.
UnexpectedCloseTagError
UnknownEntityReferenceError
UnknownNamespaceError
UselessFunctionArgumentError
Wrapper for UselessFunctionArgument error data.
WhiteSpaceInComponentNameError
Wrapper for WhiteSpaceInComponentName error data.
WhiteSpaceInComponentTypeError
Wrapper for WhiteSpaceInComponentType error data.
Xml
XmlAttributeMap
Attributes of an XML node, such as ["color" => "blue"] in <button color="blue" />.
XmlNode
Represents one XML node tag
XmlNodeChildVec
XmlNodeChildVecSlice
C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
XmlNodeVec
XmlNodeVecSlice
C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
XmlQualifiedName
A namespace-qualified XML name (e.g. svg:rect has namespace "svg" and local name "rect").
XmlTagName
Tag of an XML node, such as the “button” in <button>Hello</button>.
XmlTextError
XmlTextPos

Enums§

CompileError
Error that can happen from the translation from XML code to Rust code - stringified, since it is only used for printing and is not exposed in the public API
CompileTarget
The target language for code compilation
ComponentArgumentVecDestructor
ComponentCallbackArgVecDestructor
ComponentDataFieldVecDestructor
ComponentDataModelVecDestructor
ComponentDefVecDestructor
ComponentDefaultValue
Default value for a component field.
ComponentEnumModelVecDestructor
ComponentEnumVariantVecDestructor
ComponentError
ComponentFieldNamedValueVecDestructor
ComponentFieldOverrideVecDestructor
ComponentFieldType
Rich type descriptor for a component field. Replaces the old AzString type names (“String”, “bool”, etc.) with a structured enum that the debugger can use for type-aware editing.
ComponentFieldValue
Runtime value for a component field — the “instance” counterpart to ComponentFieldType (which is the “class” / type descriptor).
ComponentFieldValueSource
How a field value is sourced at the instance level.
ComponentFieldValueVecDestructor
ComponentLibraryVecDestructor
ComponentParseError
ComponentSource
Source of a component definition — determines whether it can be exported
DomXmlParseError
DynamicItem
Item of a split string - either a variable name (with optional format spec) or a string
ExternalResourceKind
Classification of an external resource referenced in HTML/XML
ExternalResourceVecDestructor
OptionComponentArgument
OptionComponentCallbackArg
OptionComponentDataField
OptionComponentDataModel
OptionComponentDef
OptionComponentDefaultValue
OptionComponentEnumModel
OptionComponentEnumVariant
OptionComponentFieldNamedValue
OptionComponentFieldOverride
OptionComponentFieldValue
OptionComponentLibrary
OptionExternalResource
OptionMimeTypeHint
OptionXmlNode
OptionXmlNodeChild
RenderDomError
ResultStringCompileError
ResultStyledDomRenderDomError
ResultXmlXmlError
XmlError
XmlNodeChild
Represents a child of an XML node - either an element or text
XmlNodeChildVecDestructor
XmlNodeType
Type of an XML node in the parsed tree.
XmlNodeVecDestructor
XmlParseError
XmlStreamError
c_void
Opaque void type for FFI pointers. Uses a custom definition instead of core::ffi::c_void for #[repr(C)] compatibility in the generated API.

Traits§

DomXmlExt
Extension trait to add XML parsing capabilities to Dom

Functions§

compile_body_node_to_rust_code
compile_component
domxml_from_file
Loads, parses and builds a DOM from an XML file
domxml_from_str
find_attribute
format_args_dynamic
Given a string and a key => value mapping, replaces parts of the string with the value, i.e.:
get_body_node
Find the one and only <body> node, return error if there is no app node or there are multiple app nodes
get_html_node
Find the one and only <body> node, return error if there is no app node or there are multiple app nodes
get_item
Given a root node, traverses along the hierarchy, and returns a mutable reference to the last child node of the root node
normalize_casing
Normalizes input such as abcDef, AbcDef, abc-def to the normalized form of abc_def
parse_bool
Parses a string (“true” or “false”)
parse_xml
parse_xml_string
Parses the XML string into an XML tree, returns the root <app></app> node, with the children attached to it.
parse_xml_to_fast_dom
Fastest path: parse XML string directly into FastDom without intermediate XmlNode tree. Feeds XML tokenizer events directly into CompactDomBuilder, skipping both the XmlNode tree construction AND the Dom tree construction. Parse XML string directly into a FastDom (arena-based DOM) in a single pass.
parse_xml_to_styled_dom
Parse XML directly into FastDom + extracted CSS, ready for StyledDom.
prepare_string
register_builtin_components
Register the 52 built-in HTML element components.
split_dynamic_string
Splits a string into formatting arguments, supporting format specifiers like {var:?}
str_to_dom
Parses an XML string and returns a StyledDom with the components instantiated in the <app></app>
str_to_dom_unstyled
Parses XML nodes and returns a Dom with CSS stylesheets attached (but not applied).
str_to_rust_code
Parses an XML string and returns a String, which contains the Rust source code (i.e. it compiles the XML to valid Rust)
tag_to_node_type
Map a builtin tag name to its corresponding NodeType. Falls back to NodeType::Div for unknown tags.
translate_roxmltree_error
translate_roxmltree_expandedname
user_defined_compile_fn
Default compile function for user-defined (JSON-imported) components.
user_defined_render_fn
Default render function for user-defined (JSON-imported) components.

Type Aliases§

ComponentArgumentVecDestructorType
ComponentCallbackArgVecDestructorType
ComponentCompileFn
Compile function type: takes component definition + target language + data model, returns source code.
ComponentDataFieldVecDestructorType
ComponentDataModelVecDestructorType
ComponentDefVecDestructorType
ComponentEnumModelVecDestructorType
ComponentEnumVariantVecDestructorType
ComponentFieldNamedValueVecDestructorType
ComponentFieldOverrideVecDestructorType
ComponentFieldValueVecDestructorType
ComponentLibraryVecDestructorType
ComponentRenderFn
Render function type: takes component definition + data model (with current values in default_value fields) + component map for recursive sub-component instantiation, returns StyledDom.
ExternalResourceVecDestructorType
RegisterComponentFnType
Raw function pointer type that returns a single ComponentDef when called. Used as the cb field in RegisterComponentFn.
RegisterComponentLibraryFnType
Raw function pointer type that returns a complete ComponentLibrary when called. Used as the cb field in RegisterComponentLibraryFn.
SyntaxError
Error that can occur during XML parsing or hot-reload.
XmlNodeChildVecDestructorType
XmlNodeVecDestructorType
XmlTextContent
(Unparsed) text content of an XML node, such as the “Hello” in <button>Hello</button>.