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 does not claim XML Schema or clause-level ISO conformance, byte-identical
26//! output, ISO 23386 governance workflows, or ISO 12006-3 mapping. Parsing and
27//! validation are deliberately separate operations.
28//!
29//! The ISO XSD is **not vendored** here. Redistribution rights do not follow
30//! from possessing a standards document or annex, so restricted references
31//! remain local and outside Git, crate packages, and documentation artifacts.
32
33#![forbid(unsafe_code)]
34
35mod document;
36mod domain;
37mod model;
38mod parser;
39mod value;
40
41pub use document::{Attribute, Document, Element, Node, WriteError, XmlDeclaration};
42pub use domain::{
43 DataTemplate, DataType, DataTypeConstraint, DataValue, Dimension, GroupOfProperties,
44 ObjectType, Property, QuantityKind, ReferenceDocument, Subject, Unit, ValueList,
45};
46pub use model::{
47 ConceptRef, DataTemplateElement, DataTemplateRef, DataTypeRef, Diagnostic, DiagnosticCode,
48 DimensionElement, ElementKind, GroupOfPropertiesElement, Library, LibraryElement, LibraryItem,
49 ModelError, MultilingualTextRef, ObjectTypeElement, PropertyElement, PropertyRef,
50 QuantityKindElement, ReferenceDocumentElement, ReferenceRef, Severity, SubjectElement,
51 UnitElement,
52};
53pub use parser::{ParseError, ParseErrorKind, ParseOptions};
54pub use value::{
55 AnyUri, Base, Concept, DataTypeName, DateTime, Decimal, Guid, Language, MultiLanguageText,
56 PositiveInteger, Rational, Reference, Scale, ValueError, ValueErrorKind,
57};
58
59/// The XML namespace declared by ISO 23387 edition 2.
60///
61/// Readers retain this identity rather than treating draft namespaces as the
62/// edition 2 standard.
63pub const NAMESPACE: &str = "https://standards.iso.org/iso/23387/ed-2/en/";
64
65/// A placeholder namespace found in pre-release ISO 23387 schema drafts.
66///
67/// It is named so future readers can produce a specific non-conformance
68/// diagnostic instead of silently treating draft documents as edition 2.
69pub const DRAFT_PLACEHOLDER_NAMESPACE: &str = "http://tempuri.org/XMLSchema.xsd";
70
71#[cfg(test)]
72mod tests {
73 use super::*;
74
75 #[test]
76 fn namespace_identities_match_the_documented_contracts() {
77 assert_eq!(NAMESPACE, "https://standards.iso.org/iso/23387/ed-2/en/");
78 assert_eq!(
79 DRAFT_PLACEHOLDER_NAMESPACE,
80 "http://tempuri.org/XMLSchema.xsd"
81 );
82 assert_ne!(NAMESPACE, DRAFT_PLACEHOLDER_NAMESPACE);
83 }
84}