From a0120131e696c7e36ffef49cdd02c3a21cc91916 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 13 Nov 2026 06:45:28 -0500 Subject: [PATCH] Add shared designmap root and include builders --- crates/idml/src/lib.rs | 5 ++++- crates/idml/src/part.rs | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/crates/idml/src/lib.rs b/crates/idml/src/lib.rs index 1206a34f3..f7a698c34 100644 --- a/crates/idml/src/lib.rs +++ b/crates/idml/src/lib.rs @@ -39,7 +39,10 @@ pub mod value; pub use craft_xml::{El, Local, Node}; pub use package::{Document, Limits, Package, write_package}; -pub use part::{CONTAINER_XML, Props, designmap_xml, designmap_xml_with_pi, parse_part, part_root, part_xml, prop, with_props, xml_limits}; +pub use part::{ + CONTAINER_XML, Props, designmap_include, designmap_root, designmap_xml, designmap_xml_with_pi, parse_part, part_root, part_xml, prop, with_props, + xml_limits, +}; /// The IDML package mimetype (content of the first, stored `mimetype` entry). pub const MIMETYPE: &str = "application/vnd.adobe.indesign-idml-package"; diff --git a/crates/idml/src/part.rs b/crates/idml/src/part.rs index e6b7385c5..e454737a2 100644 --- a/crates/idml/src/part.rs +++ b/crates/idml/src/part.rs @@ -16,6 +16,25 @@ pub const fn xml_limits() -> craft_xml::Limits { /// `META-INF/container.xml` of a package. pub const CONTAINER_XML: &str = "\n\n\t\n\t\t\n\t\n\n"; +/// The standard root element for `designmap.xml`, including its required namespace and core +/// document identity fields. The caller supplies DesignCraft-independent values; children are +/// appended after construction. +pub fn designmap_root(self_id: &str, story_list: &str, name: &str, zero_point: &str, active_layer: &str) -> El { + El::new("Document") + .with_attr("xmlns:idPkg", PACKAGING_NS) + .with_attr("DOMVersion", DOM_VERSION) + .with_attr("Self", self_id) + .with_attr("StoryList", story_list) + .with_attr("Name", name) + .with_attr("ZeroPoint", zero_point) + .with_attr("ActiveLayer", active_layer) +} + +/// An `idPkg` reference in `designmap.xml` to a part stored at `src`. +pub fn designmap_include(kind: &str, src: &str) -> El { + El::new(format!("idPkg:{kind}")).with_attr("src", src) +} + /// Parses a part into its root element with [`xml_limits`]. /// /// Names are kept as written (`idPkg:Story`), text is kept exactly (it is story content), CDATA