Skip to main content

openbim_dt/
lib.rs

1//! `openbim-dt` — ISO 23387 data templates.
2//!
3//! # What this is
4//!
5//! The concept vocabulary that describes *properties themselves*: property
6//! definitions, groups of properties, quantity kinds, dimensions, units,
7//! object types, and the reference machinery binding them to external
8//! dictionaries such as bSDD.
9//!
10//! # Why it is a crate and not part of `openbim-loin`
11//!
12//! LOIN does not own ISO 23387. The ISO 7817-3 schema imports the ISO 23387
13//! namespace and uses its types. Data-template tooling and dictionary clients
14//! also need the vocabulary without acquiring a LOIN dependency.
15//!
16//! The dependency direction is therefore `openbim-loin` to `openbim-dt`, never
17//! the reverse.
18//!
19//! # Status
20//!
21//! The crate implements validated lexical contracts, a bounded namespace-aware
22//! parser, semantic XML round trips with unknown-content retention, owned type
23//! contracts and typed global/local DT element views, diagnostics, and a CLI.
24//!
25//! It also implements XML Schema validation of the ISO 23387 element grammar
26//! ([`Document::validate_schema`]) and byte-identical round trips
27//! ([`Document::to_xml_string_exact`]).
28//!
29//! It does not claim full clause-level ISO conformance, ISO 23386 governance
30//! workflows, or ISO 12006-3 mapping. Parsing and validation are deliberately
31//! separate operations.
32//!
33//! The ISO XSD is **not vendored** here. Redistribution rights do not follow
34//! from possessing a standards document or annex, so restricted references
35//! remain local and outside Git, crate packages, and documentation artifacts.
36
37#![forbid(unsafe_code)]
38
39mod codec;
40mod conformance;
41mod document;
42mod domain;
43mod model;
44mod parser;
45mod schema;
46mod value;
47
48pub use codec::{CodecError, CodecErrorKind};
49pub use conformance::{SchemaReport, SchemaViolation, SchemaViolationCode};
50
51pub use document::{
52    Attribute, Document, Element, ExactWriteError, Node, WriteError, XmlDeclaration,
53};
54pub use domain::{
55    DataTemplate, DataType, DataTypeConstraint, DataValue, Dimension, GroupOfProperties,
56    ObjectType, Property, QuantityKind, ReferenceDocument, Subject, Unit, ValueList,
57};
58pub use model::{
59    ConceptRef, DataTemplateElement, DataTemplateRef, DataTypeRef, Diagnostic, DiagnosticCode,
60    DimensionElement, ElementKind, GroupOfPropertiesElement, Library, LibraryElement, LibraryItem,
61    ModelError, MultilingualTextRef, ObjectTypeElement, PropertyElement, PropertyRef,
62    QuantityKindElement, ReferenceDocumentElement, ReferenceRef, Severity, SubjectElement,
63    UnitElement,
64};
65pub use parser::{ParseError, ParseErrorKind, ParseOptions};
66pub use value::{
67    AnyUri, Base, Base64Binary, Concept, DataTypeName, DateTime, Decimal, Guid, Language,
68    MultiLanguageText, NonNegativeInteger, PositiveInteger, Rational, Reference, Scale, ValueError,
69    ValueErrorKind,
70};
71
72/// The XML namespace declared by ISO 23387 edition 2.
73///
74/// Readers retain this identity rather than treating draft namespaces as the
75/// edition 2 standard.
76pub const NAMESPACE: &str = "https://standards.iso.org/iso/23387/ed-2/en/";
77
78/// A placeholder namespace found in pre-release ISO 23387 schema drafts.
79///
80/// It is named so future readers can produce a specific non-conformance
81/// diagnostic instead of silently treating draft documents as edition 2.
82pub const DRAFT_PLACEHOLDER_NAMESPACE: &str = "http://tempuri.org/XMLSchema.xsd";
83
84#[cfg(test)]
85mod tests {
86    use super::*;
87
88    #[test]
89    fn namespace_identities_match_the_documented_contracts() {
90        assert_eq!(NAMESPACE, "https://standards.iso.org/iso/23387/ed-2/en/");
91        assert_eq!(
92            DRAFT_PLACEHOLDER_NAMESPACE,
93            "http://tempuri.org/XMLSchema.xsd"
94        );
95        assert_ne!(NAMESPACE, DRAFT_PLACEHOLDER_NAMESPACE);
96    }
97}