Expand description
FO tree data structures
This module provides the tree structure for storing formatting objects. Uses arena allocation with index-based handles for memory efficiency.
§Architecture
- Arena allocation: All nodes stored in contiguous memory (cache-friendly)
- Index-based handles: NodeId is just usize (no Rc/RefCell overhead)
- Tree builder: SAX-like parser that constructs tree from XML events
- Validation: Element nesting rules enforcement
§Example
use fop_core::FoTreeBuilder;
use std::io::Cursor;
let xml = r#"<?xml version="1.0"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="A4">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
</fo:root>"#;
let builder = FoTreeBuilder::new();
let arena = builder.parse(Cursor::new(xml)).unwrap();
println!("Parsed {} nodes", arena.len());Re-exports§
pub use arena::FoArena;pub use arena::NodeId;pub use builder::FoTreeBuilder;pub use id_registry::IdRegistry;pub use node::BlankOrNotBlank;pub use node::FoNode;pub use node::FoNodeData;pub use node::OddOrEven;pub use node::PagePosition;pub use node::RetrievePosition;pub use validation::NestingValidator;
Modules§
- arena
- Arena allocator for FO tree nodes
- builder
- FO tree builder - constructs the FO tree from XML
- id_
registry - ID registry for tracking element IDs and cross-references
- node
- FO tree node data structures
- validation
- Element nesting validation