openbim_dt/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! `openbim-dt` — ISO 23387 data templates.
//!
//! # What this is
//!
//! The concept vocabulary that describes *properties themselves*: property
//! definitions, groups of properties, quantity kinds, dimensions, units,
//! object types, and the reference machinery binding them to external
//! dictionaries such as bSDD.
//!
//! # Why it is a crate and not part of `openbim-loin`
//!
//! LOIN does not own ISO 23387. The ISO 7817-3 schema imports the ISO 23387
//! namespace and uses its types. Data-template tooling and dictionary clients
//! also need the vocabulary without acquiring a LOIN dependency.
//!
//! The dependency direction is therefore `openbim-loin` to `openbim-dt`, never
//! the reverse.
//!
//! # Status
//!
//! The crate implements validated lexical contracts, a bounded namespace-aware
//! parser, semantic XML round trips with unknown-content retention, owned type
//! contracts and typed global/local DT element views, diagnostics, and a CLI.
//!
//! It also implements XML Schema validation of the ISO 23387 element grammar
//! ([`Document::validate_schema`]) and byte-identical round trips
//! ([`Document::to_xml_string_exact`]).
//!
//! It does not claim full clause-level ISO conformance, ISO 23386 governance
//! workflows, or ISO 12006-3 mapping. Parsing and validation are deliberately
//! separate operations.
//!
//! The ISO XSD is **not vendored** here. Redistribution rights do not follow
//! from possessing a standards document or annex, so restricted references
//! remain local and outside Git, crate packages, and documentation artifacts.

#![forbid(unsafe_code)]

mod conformance;
mod document;
mod domain;
mod model;
mod parser;
mod schema;
mod value;

pub use conformance::{SchemaReport, SchemaViolation, SchemaViolationCode};

pub use document::{
    Attribute, Document, Element, ExactWriteError, Node, WriteError, XmlDeclaration,
};
pub use domain::{
    DataTemplate, DataType, DataTypeConstraint, DataValue, Dimension, GroupOfProperties,
    ObjectType, Property, QuantityKind, ReferenceDocument, Subject, Unit, ValueList,
};
pub use model::{
    ConceptRef, DataTemplateElement, DataTemplateRef, DataTypeRef, Diagnostic, DiagnosticCode,
    DimensionElement, ElementKind, GroupOfPropertiesElement, Library, LibraryElement, LibraryItem,
    ModelError, MultilingualTextRef, ObjectTypeElement, PropertyElement, PropertyRef,
    QuantityKindElement, ReferenceDocumentElement, ReferenceRef, Severity, SubjectElement,
    UnitElement,
};
pub use parser::{ParseError, ParseErrorKind, ParseOptions};
pub use value::{
    AnyUri, Base, Concept, DataTypeName, DateTime, Decimal, Guid, Language, MultiLanguageText,
    PositiveInteger, Rational, Reference, Scale, ValueError, ValueErrorKind,
};

/// The XML namespace declared by ISO 23387 edition 2.
///
/// Readers retain this identity rather than treating draft namespaces as the
/// edition 2 standard.
pub const NAMESPACE: &str = "https://standards.iso.org/iso/23387/ed-2/en/";

/// A placeholder namespace found in pre-release ISO 23387 schema drafts.
///
/// It is named so future readers can produce a specific non-conformance
/// diagnostic instead of silently treating draft documents as edition 2.
pub const DRAFT_PLACEHOLDER_NAMESPACE: &str = "http://tempuri.org/XMLSchema.xsd";

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn namespace_identities_match_the_documented_contracts() {
        assert_eq!(NAMESPACE, "https://standards.iso.org/iso/23387/ed-2/en/");
        assert_eq!(
            DRAFT_PLACEHOLDER_NAMESPACE,
            "http://tempuri.org/XMLSchema.xsd"
        );
        assert_ne!(NAMESPACE, DRAFT_PLACEHOLDER_NAMESPACE);
    }
}