openehr-its 0.0.128

openEHR ITS (Implementation Technology Specifications): canonical JSON + canonical XML serialization of the RM, the generated ITS-REST 1.1.0 API contract, and the OPT 1.4 and AOM2 archetype XML codecs
Documentation
// @generated by openehr-codegen (emit-aom2) — DO NOT EDIT.
// SPDX-FileCopyrightText: Cadasto B.V.
// SPDX-FileCopyrightText: openEHR Foundation
// SPDX-License-Identifier: Apache-2.0
//! openEHR AOM2 persistent-form archetype model + canonical-XML codec.
//!
//! Parse a persistent-form AOM2 archetype with [`from_xml`]; the root element is `<archetype>` (`P_AUTHORED_ARCHETYPE`).
//!
//! This is the PERSISTENT (`P_AOM`) AOM2 serialization — `P_Archetype.xsd`, whose
//! own header calls it "uses P_AOM types - much more space efficient". It is the
//! form the bundle's 8 `AOM2/examples/*.xml` documents carry
//! (`xsi:schemaLocation="… ../P_Archetype.xsd"`). The bundle's other archetype
//! serialization — the AOM model form — is [`crate::aom2_model`].

mod impls;
pub mod types;

/// Parse a persistent-form AOM2 archetype XML document into a [`types::PAuthoredArchetype`].
///
/// # Errors
/// Propagates canonical-XML parse errors, and refuses a root element other
/// than `<archetype>`.
pub fn from_xml(xml: &str) -> Result<types::PAuthoredArchetype, crate::xml::runtime::XmlError> {
    crate::xml::runtime::from_xml_rooted(xml, "archetype")
}

/// Serialize a [`types::PAuthoredArchetype`] back to AOM2 persistent-form archetype XML (root `<archetype>`,
/// `http://schemas.openehr.org/v1`).
///
/// # Errors
/// Propagates canonical-XML serialization errors.
pub fn to_xml(value: &types::PAuthoredArchetype) -> Result<String, crate::xml::runtime::XmlError> {
    crate::xml::runtime::to_xml(value, "archetype", crate::xml::runtime::Namespace::V1)
}