Expand description
XML and XHTML parsing for declarative UI definitions. XML and XHTML parsing for declarative UI definitions.
This module provides comprehensive XML parsing and manipulation for Azul’s XML-based
UI format (.azul files). It supports:
- XHTML parsing: Parse HTML-like syntax into DOM structures
- CSS extraction: Extract
<style>blocks and inline styles - Component system: Define reusable UI components with arguments
- Hot reload: Track file changes and rebuild UI incrementally
- Error reporting: Detailed syntax error messages with line/column info
§Examples
ⓘ
use azul_core::xml::{XmlNode, XmlParseOptions};
let xml = "<div>Hello</div>";
// let node = XmlNode::parse(xml)?;Structs§
- Compact
DomBuilder - Builder for arena-based DOM construction (FastDom). Builds two parallel Vecs (hierarchy + node_data) in a single DFS pass.
- Component
Argument - FFI-safe replacement for
(ComponentArgumentName, ComponentArgumentType)tuple. - Component
Argument Vec - Component
Argument VecSlice - C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
- Component
Arguments - Holds the list of arguments and whether the component accepts text content. Used by the compile pipeline to generate Rust function signatures.
- Component
Callback Arg - A single argument in a callback signature.
- Component
Callback ArgVec - Component
Callback ArgVec Slice - C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
- Component
Callback Signature - Callback signature: return type + argument list.
- Component
Data Field - A field in the component’s internal data model.
- Component
Data Field Vec - Component
Data Field VecSlice - C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
- Component
Data Model - A named data model (struct definition) for code generation.
- Component
Data Model Vec - Component
Data Model VecSlice - C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
- Component
Def - A component definition — the “class” / “template” of a component. Can come from Rust builtins, compiled widgets, JSON, or user creation in debugger.
- Component
DefVec - Component
DefVec Slice - C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
- Component
Enum Model - A named enum model for code generation.
Stored in
ComponentLibrary::enum_models. - Component
Enum Model Vec - Component
Enum Model VecSlice - C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
- Component
Enum Variant - A single variant in a component enum model.
- Component
Enum Variant Vec - Component
Enum Variant VecSlice - C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
- Component
Field Named Value - Named field value: (field_name, value) pair.
- Component
Field Named Value Vec - Component
Field Named Value VecSlice - C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
- Component
Field Override - An override for a single field in a component instance.
- Component
Field Override Vec - Component
Field Override VecSlice - C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
- Component
Field Type Box - Heap-allocated box for recursive
ComponentFieldType(e.g.Option<String>). Uses raw pointer indirection to break the infinite size. - Component
Field Value Box - Heap-allocated box for recursive
ComponentFieldValue(e.g.Some(value)). Uses raw pointer indirection to break the infinite size. - Component
Field Value Vec - Component
Field Value VecSlice - C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
- Component
Id - 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. - Component
Instance Default - Default component instance for a StyledDom slot.
- Component
Library - A named collection of component definitions
- Component
Library Vec - Component
Library VecSlice - C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
- Component
Map - 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. - Duplicated
Attribute Error - Duplicated
Namespace Error - External
Resource - An external resource URL found in an XML/HTML document
- External
Resource Vec - External
Resource VecSlice - C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
- Invalid
Char Error - Invalid
Char Multiple Error - Invalid
Quote Error - Invalid
Space Error - Invalid
String Error - Malformed
Hierarchy Error - Error for mismatched open/close tags in XML hierarchy
- Mime
Type Hint - MIME type hint for an external resource
- Missing
Type Error - Wrapper for MissingType error data.
- NonXml
Char Error - Register
Component Fn - Callback struct for registering individual components at startup.
- Register
Component Library Fn - Callback struct for registering entire component libraries at startup.
- Unexpected
Close TagError - Unknown
Entity Reference Error - Unknown
Namespace Error - Useless
Function Argument Error - Wrapper for UselessFunctionArgument error data.
- White
Space InComponent Name Error - Wrapper for WhiteSpaceInComponentName error data.
- White
Space InComponent Type Error - Wrapper for WhiteSpaceInComponentType error data.
- Xml
- XmlAttribute
Map - Attributes of an XML node, such as
["color" => "blue"]in<button color="blue" />. - XmlNode
- Represents one XML node tag
- XmlNode
Child Vec - XmlNode
Child VecSlice - C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
- XmlNode
Vec - XmlNode
VecSlice - C-compatible slice type for $struct_name. This is a non-owning view into a Vec’s data.
- XmlQualified
Name - A namespace-qualified XML name (e.g.
svg:recthas namespace"svg"and local name"rect"). - XmlTag
Name - Tag of an XML node, such as the “button” in
<button>Hello</button>. - XmlText
Error - XmlText
Pos
Enums§
- Compile
Error - 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
- Compile
Target - The target language for code compilation
- Component
Argument VecDestructor - Component
Callback ArgVec Destructor - Component
Data Field VecDestructor - Component
Data Model VecDestructor - Component
DefVec Destructor - Component
Default Value - Default value for a component field.
- Component
Enum Model VecDestructor - Component
Enum Variant VecDestructor - Component
Error - Component
Field Named Value VecDestructor - Component
Field Override VecDestructor - Component
Field Type - Rich type descriptor for a component field.
Replaces the old
AzStringtype names (“String”, “bool”, etc.) with a structured enum that the debugger can use for type-aware editing. - Component
Field Value - Runtime value for a component field — the “instance” counterpart
to
ComponentFieldType(which is the “class” / type descriptor). - Component
Field Value Source - How a field value is sourced at the instance level.
- Component
Field Value VecDestructor - Component
Library VecDestructor - Component
Parse Error - Component
Source - Source of a component definition — determines whether it can be exported
- DomXml
Parse Error - Dynamic
Item - Item of a split string - either a variable name (with optional format spec) or a string
- External
Resource Kind - Classification of an external resource referenced in HTML/XML
- External
Resource VecDestructor - Option
Component Argument - Option
Component Callback Arg - Option
Component Data Field - Option
Component Data Model - Option
Component Def - Option
Component Default Value - Option
Component Enum Model - Option
Component Enum Variant - Option
Component Field Named Value - Option
Component Field Override - Option
Component Field Value - Option
Component Library - Option
External Resource - Option
Mime Type Hint - Option
XmlNode - Option
XmlNode Child - Render
DomError - Result
String Compile Error - Result
Styled DomRender DomError - Result
XmlXml Error - XmlError
- XmlNode
Child - Represents a child of an XML node - either an element or text
- XmlNode
Child VecDestructor - XmlNode
Type - Type of an XML node in the parsed tree.
- XmlNode
VecDestructor - XmlParse
Error - XmlStream
Error - c_void
- Opaque void type for FFI pointers. Uses a custom definition instead of
core::ffi::c_voidfor#[repr(C)]compatibility in the generated API.
Functions§
- compile_
body_ node_ to_ rust_ code - compile_
component - 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-defto the normalized form ofabc_def - parse_
bool - Parses a string (“true” or “false”)
- 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
StyledDomwith the components instantiated in the<app></app> - str_
to_ dom_ unstyled - Parses XML nodes and returns a
Domwith 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 toNodeType::Divfor unknown tags. - 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§
- Component
Argument VecDestructor Type - Component
Callback ArgVec Destructor Type - Component
Compile Fn - Compile function type: takes component definition + target language + data model, returns source code.
- Component
Data Field VecDestructor Type - Component
Data Model VecDestructor Type - Component
DefVec Destructor Type - Component
Enum Model VecDestructor Type - Component
Enum Variant VecDestructor Type - Component
Field Named Value VecDestructor Type - Component
Field Override VecDestructor Type - Component
Field Value VecDestructor Type - Component
Library VecDestructor Type - Component
Render Fn - Render function type: takes component definition + data model (with current values
in
default_valuefields) + component map for recursive sub-component instantiation, returns StyledDom. - External
Resource VecDestructor Type - Register
Component FnType - Raw function pointer type that returns a single ComponentDef when called.
Used as the
cbfield inRegisterComponentFn. - Register
Component Library FnType - Raw function pointer type that returns a complete ComponentLibrary when called.
Used as the
cbfield inRegisterComponentLibraryFn. - Syntax
Error - Error that can occur during XML parsing or hot-reload.
- XmlNode
Child VecDestructor Type - XmlNode
VecDestructor Type - XmlText
Content - (Unparsed) text content of an XML node, such as the “Hello” in
<button>Hello</button>.