Skip to main content

fop_core/tree/
mod.rs

1//! FO tree data structures
2//!
3//! This module provides the tree structure for storing formatting objects.
4//! Uses arena allocation with index-based handles for memory efficiency.
5//!
6//! # Architecture
7//!
8//! - **Arena allocation**: All nodes stored in contiguous memory (cache-friendly)
9//! - **Index-based handles**: NodeId is just usize (no Rc/RefCell overhead)
10//! - **Tree builder**: SAX-like parser that constructs tree from XML events
11//! - **Validation**: Element nesting rules enforcement
12//!
13//! # Example
14//!
15//! ```no_run
16//! use fop_core::FoTreeBuilder;
17//! use std::io::Cursor;
18//!
19//! let xml = r#"<?xml version="1.0"?>
20//! <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
21//!     <fo:layout-master-set>
22//!         <fo:simple-page-master master-name="A4">
23//!             <fo:region-body/>
24//!         </fo:simple-page-master>
25//!     </fo:layout-master-set>
26//! </fo:root>"#;
27//!
28//! let builder = FoTreeBuilder::new();
29//! let arena = builder.parse(Cursor::new(xml)).unwrap();
30//!
31//! println!("Parsed {} nodes", arena.len());
32//! ```
33
34pub mod arena;
35pub mod builder;
36pub mod id_registry;
37pub mod node;
38pub mod validation;
39
40pub use arena::{FoArena, NodeId};
41pub use builder::FoTreeBuilder;
42pub use id_registry::IdRegistry;
43pub use node::{BlankOrNotBlank, FoNode, FoNodeData, OddOrEven, PagePosition, RetrievePosition};
44pub use validation::NestingValidator;