Skip to main content

Crate rdocx_oxml

Crate rdocx_oxml 

Source
Expand description

§rdocx-oxml

rdocx-oxml provides typed WordprocessingML elements with prefix-tolerant parsing, schema-ordered serialization, and verbatim preservation of unmodelled XML.

§Use it when

Use this crate when a tool already owns the XML model. Most applications should use the package-preserving rdocx facade instead.

§Relationship

rdocx owns complete DOCX packages and uses these types for WordprocessingML parts. The shared oxml-* crates remain format-neutral.

§Example

use rdocx_oxml::{BodyContent, CT_Document, CT_P};

let mut document = CT_Document::new();
let mut paragraph = CT_P::new();
paragraph.add_run("Low-level WordprocessingML");
document.body.content.push(BodyContent::Paragraph(paragraph));

assert_eq!(document.body.paragraphs().count(), 1);
[dependencies]
rdocx-oxml = "0.6"

§Migrating from 0.4

Version 0.5 adds explicit preservation state to the public numbering structs. Code that constructs CT_Lvl, CT_AbstractNum, CT_Num, or CT_Numbering with a full struct literal must supply the new raw XML fields. Prefer CT_Lvl::new, CT_AbstractNum::new, and CT_Numbering::new. When a literal is required, CT_Lvl adds empty extra_xml and extra_attributes vectors plus ppr_raw: None and rpr_raw: None. CT_AbstractNum and CT_Num add empty extra_xml and extra_attributes vectors. CT_Numbering adds empty root_attributes and extra_xml vectors. These fields retain producer XML during typed numbering edits and are intentionally part of the 0.5 model.

CT_TabStop full literals also add source_occurrence: None. Parsed numbering tabs use this field to keep producer XML attached to the same occurrence after typed edits, insertions, or removals. CT_TabStop::new initializes it for a new tab. Semantic equality ignores the field and continues to compare alignment, position, and leader values. CT_Tabs::from_xml_with_prefixes accepts the in-scope WordprocessingML prefixes when callers parse aliased tab collections directly. Numbering, style, and document-family readers route complete paragraph property subtrees through one internal namespace projection rather than exposing a partially contextual public CT_PPr parser.

Re-exports§

pub use borders::CT_BorderEdge;
pub use borders::CT_PBdr;
pub use borders::CT_TabStop;
pub use borders::CT_Tabs;
pub use document::BodyContent;
pub use document::CT_Body;
pub use document::CT_Document;
pub use document::CT_SectPr;
pub use numbering::CT_AbstractNum;
pub use numbering::CT_Lvl;
pub use numbering::CT_Num;
pub use numbering::CT_Numbering;
pub use numbering::ST_NumberFormat;
pub use properties::CT_PPr;
pub use properties::CT_RPr;
pub use shared::ST_Border;
pub use shared::ST_Jc;
pub use shared::ST_OnOff;
pub use shared::ST_PageOrientation;
pub use shared::ST_SectionType;
pub use shared::ST_TabJc;
pub use shared::ST_TabLeader;
pub use styles::CT_DocDefaults;
pub use styles::CT_Style;
pub use styles::CT_Styles;
pub use table::CT_Row;
pub use table::CT_Tbl;
pub use table::CT_TblGrid;
pub use table::CT_TblPr;
pub use table::CT_Tc;
pub use table::CT_TcPr;
pub use text::CT_P;
pub use text::CT_R;
pub use text::CT_Text;

Modules§

borders
Border and tab stop types for paragraph formatting.
core_properties
Dublin Core metadata from docProps/core.xml.
document
Document-level elements: CT_Document and CT_Body.
drawing
Drawing elements for inline and anchor images: CT_Drawing, CT_Inline, CT_Anchor.
error
Error types for OXML parsing.
footnotes
Footnote and endnote elements: CT_Footnotes, CT_Footnote.
header_footer
Header and footer elements: CT_HdrFtr.
namespace
OOXML namespace constants.
numbering
Numbering definitions: CT_Numbering, CT_AbstractNum, CT_Num, CT_Lvl.
placeholder
Placeholder replacement across paragraphs, tables, and headers/footers.
properties
Paragraph properties (CT_PPr) and run properties (CT_RPr).
raw_xml
Raw XML capture utilities for preserving unknown elements during round-trip.
shared
Shared simple types and enums used across OOXML elements.
styles
Style elements: CT_Styles, CT_Style, CT_DocDefaults.
table
Table elements: CT_Tbl, CT_Row, CT_Tc and related types.
text
Text content elements: CT_P (paragraph), CT_R (run), CT_Text.
theme
Theme parsing: extracts color scheme and font scheme from theme1.xml.
units
Unit types for OOXML measurements.

Structs§

Emu
English Metric Units — 1/914400 of an inch. Used for drawing coordinates and image sizing.
HalfPoint
Half-points — 1/2 of a point, or 1/144 of an inch. Used for font sizes (e.g., 24 half-points = 12pt).
Twips
Twips — 1/20 of a point, or 1/1440 of an inch. Used for page dimensions, margins, spacing, indentation.

Enums§

OxmlError

Type Aliases§

Result