#![allow(
non_snake_case,
clippy::all,
clippy::pedantic,
clippy::nursery,
unused_variables,
unused_mut,
unused_qualifications,
unused_imports,
reason = "mechanically generated codec text: every runtime item is named by its full path and every branch shape is emitted uniformly, so style and unused-binding lints do not apply — the hand-written runtime carries the lint bar"
)]
use crate::xml::runtime::{FromXml, ToXml, XmlError, XmlEvent};
impl crate::xml::runtime::ToXml for crate::opt14::types::OperatorKind {
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
_declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
w.write_text_element(tag, self.as_wire())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::OperatorKind {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let __s = <::std::string::String as crate::xml::runtime::FromXml>::from_xml(reader, start)?;
crate::opt14::types::OperatorKind::from_wire(__s.trim()).map_err(|__e| {
crate::xml::runtime::XmlError::parse_source("element text of OPERATOR_KIND", __e)
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::ProportionKind {
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
_declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
w.write_text_element(tag, self.as_wire())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::ProportionKind {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let __s = <::std::string::String as crate::xml::runtime::FromXml>::from_xml(reader, start)?;
crate::opt14::types::ProportionKind::from_wire(__s.trim()).map_err(|__e| {
crate::xml::runtime::XmlError::parse_source("element text of PROPORTION_KIND", __e)
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::ValidityKind {
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
_declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
w.write_text_element(tag, self.as_wire())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::ValidityKind {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let __s = <::std::string::String as crate::xml::runtime::FromXml>::from_xml(reader, start)?;
crate::opt14::types::ValidityKind::from_wire(__s.trim()).map_err(|__e| {
crate::xml::runtime::XmlError::parse_source("element text of VALIDITY_KIND", __e)
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::Annotation {
fn xml_type_name(&self) -> &'static str {
"ANNOTATION"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "ANNOTATION" {
__attrs.push(("xsi:type", "ANNOTATION".to_string()));
}
}
__attrs.push(("path", self.path.to_string()));
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
for (k, v) in &self.items {
w.write_kv_element("items", k, v)?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::Annotation {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __items = indexmap::IndexMap::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"items" => {
let __k = __c
.attr("id")
.ok_or_else(|| reader.missing_attribute("StringDictionaryItem", "id"))?
.to_string();
let __v: String = crate::xml::runtime::FromXml::from_xml(reader, &__c)?;
__items.insert(__k, __v);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "ANNOTATION".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::Annotation {
path: start
.attr("path")
.ok_or_else(|| reader.missing_attribute("ANNOTATION", "path"))?
.to_string(),
items: __items,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::Archetype {
fn xml_type_name(&self) -> &'static str {
"ARCHETYPE"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "ARCHETYPE" {
__attrs.push(("xsi:type", "ARCHETYPE".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.original_language
.write_xml(w, "original_language", Some("CODE_PHRASE"))?;
if let Some(v) = &self.is_controlled {
v.write_xml(w, "is_controlled", Some(""))?;
}
if let Some(v) = &self.description {
v.write_xml(w, "description", Some("RESOURCE_DESCRIPTION"))?;
}
for v in &self.translations {
v.write_xml(w, "translations", Some("TRANSLATION_DETAILS"))?;
}
if let Some(v) = &self.revision_history {
v.write_xml(w, "revision_history", Some("REVISION_HISTORY"))?;
}
if let Some(v) = &self.uid {
v.write_xml(w, "uid", Some("HIER_OBJECT_ID"))?;
}
self.archetype_id
.write_xml(w, "archetype_id", Some("ARCHETYPE_ID"))?;
if let Some(v) = &self.adl_version {
v.write_xml(w, "adl_version", Some(""))?;
}
self.concept.write_xml(w, "concept", Some(""))?;
if let Some(v) = &self.parent_archetype_id {
v.write_xml(w, "parent_archetype_id", Some("ARCHETYPE_ID"))?;
}
self.definition
.write_xml(w, "definition", Some("C_COMPLEX_OBJECT"))?;
for v in &self.invariants {
v.write_xml(w, "invariants", Some("ASSERTION"))?;
}
self.ontology
.write_xml(w, "ontology", Some("ARCHETYPE_ONTOLOGY"))?;
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::Archetype {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __original_language = None;
let mut __is_controlled = None;
let mut __description = None;
let mut __translations = Vec::new();
let mut __revision_history = None;
let mut __uid = None;
let mut __archetype_id = None;
let mut __adl_version = None;
let mut __concept = None;
let mut __parent_archetype_id = None;
let mut __definition = None;
let mut __invariants = Vec::new();
let mut __ontology = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"original_language" => {
__original_language =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"is_controlled" => {
__is_controlled =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"description" => {
__description = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"translations" => {
__translations.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"revision_history" => {
__revision_history =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"uid" => {
__uid = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"archetype_id" => {
__archetype_id =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"adl_version" => {
__adl_version = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"concept" => {
__concept = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"parent_archetype_id" => {
__parent_archetype_id =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"definition" => {
__definition = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"invariants" => {
__invariants.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"ontology" => {
__ontology = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "ARCHETYPE".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::Archetype {
original_language: __original_language
.ok_or_else(|| reader.missing_child("ARCHETYPE", "original_language"))?,
is_controlled: __is_controlled,
description: __description,
translations: __translations,
revision_history: __revision_history,
uid: __uid,
archetype_id: __archetype_id
.ok_or_else(|| reader.missing_child("ARCHETYPE", "archetype_id"))?,
adl_version: __adl_version,
concept: __concept.ok_or_else(|| reader.missing_child("ARCHETYPE", "concept"))?,
parent_archetype_id: __parent_archetype_id,
definition: __definition
.ok_or_else(|| reader.missing_child("ARCHETYPE", "definition"))?,
invariants: __invariants,
ontology: __ontology.ok_or_else(|| reader.missing_child("ARCHETYPE", "ontology"))?,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::ArchetypeConstraint {
fn xml_type_name(&self) -> &'static str {
match self {
crate::opt14::types::ArchetypeConstraint::ArchetypeInternalRef(x) => x.xml_type_name(),
crate::opt14::types::ArchetypeConstraint::ArchetypeSlot(x) => x.xml_type_name(),
crate::opt14::types::ArchetypeConstraint::ConstraintRef(x) => x.xml_type_name(),
crate::opt14::types::ArchetypeConstraint::CArchetypeRoot(x) => x.xml_type_name(),
crate::opt14::types::ArchetypeConstraint::CCodePhrase(x) => x.xml_type_name(),
crate::opt14::types::ArchetypeConstraint::CCodeReference(x) => x.xml_type_name(),
crate::opt14::types::ArchetypeConstraint::CComplexObject(x) => x.xml_type_name(),
crate::opt14::types::ArchetypeConstraint::CDefinedObject(x) => x.xml_type_name(),
crate::opt14::types::ArchetypeConstraint::CDvOrdinal(x) => x.xml_type_name(),
crate::opt14::types::ArchetypeConstraint::CDvQuantity(x) => x.xml_type_name(),
crate::opt14::types::ArchetypeConstraint::CDvState(x) => x.xml_type_name(),
crate::opt14::types::ArchetypeConstraint::CMultipleAttribute(x) => x.xml_type_name(),
crate::opt14::types::ArchetypeConstraint::CPrimitiveObject(x) => x.xml_type_name(),
crate::opt14::types::ArchetypeConstraint::CSingleAttribute(x) => x.xml_type_name(),
crate::opt14::types::ArchetypeConstraint::TComplexObject(x) => x.xml_type_name(),
}
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
match self {
crate::opt14::types::ArchetypeConstraint::ArchetypeInternalRef(x) => {
x.write_xml(w, tag, declared)
}
crate::opt14::types::ArchetypeConstraint::ArchetypeSlot(x) => {
x.write_xml(w, tag, declared)
}
crate::opt14::types::ArchetypeConstraint::ConstraintRef(x) => {
x.write_xml(w, tag, declared)
}
crate::opt14::types::ArchetypeConstraint::CArchetypeRoot(x) => {
x.write_xml(w, tag, declared)
}
crate::opt14::types::ArchetypeConstraint::CCodePhrase(x) => {
x.write_xml(w, tag, declared)
}
crate::opt14::types::ArchetypeConstraint::CCodeReference(x) => {
x.write_xml(w, tag, declared)
}
crate::opt14::types::ArchetypeConstraint::CComplexObject(x) => {
x.write_xml(w, tag, declared)
}
crate::opt14::types::ArchetypeConstraint::CDefinedObject(x) => {
x.write_xml(w, tag, declared)
}
crate::opt14::types::ArchetypeConstraint::CDvOrdinal(x) => {
x.write_xml(w, tag, declared)
}
crate::opt14::types::ArchetypeConstraint::CDvQuantity(x) => {
x.write_xml(w, tag, declared)
}
crate::opt14::types::ArchetypeConstraint::CDvState(x) => x.write_xml(w, tag, declared),
crate::opt14::types::ArchetypeConstraint::CMultipleAttribute(x) => {
x.write_xml(w, tag, declared)
}
crate::opt14::types::ArchetypeConstraint::CPrimitiveObject(x) => {
x.write_xml(w, tag, declared)
}
crate::opt14::types::ArchetypeConstraint::CSingleAttribute(x) => {
x.write_xml(w, tag, declared)
}
crate::opt14::types::ArchetypeConstraint::TComplexObject(x) => {
x.write_xml(w, tag, declared)
}
}
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::ArchetypeConstraint {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
match start.xsi_type() {
Some("ARCHETYPE_INTERNAL_REF") => Ok(
crate::opt14::types::ArchetypeConstraint::ArchetypeInternalRef(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
),
),
Some("ARCHETYPE_SLOT") => Ok(crate::opt14::types::ArchetypeConstraint::ArchetypeSlot(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("CONSTRAINT_REF") => Ok(crate::opt14::types::ArchetypeConstraint::ConstraintRef(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_ARCHETYPE_ROOT") => {
Ok(crate::opt14::types::ArchetypeConstraint::CArchetypeRoot(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
))
}
Some("C_CODE_PHRASE") => Ok(crate::opt14::types::ArchetypeConstraint::CCodePhrase(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_CODE_REFERENCE") => {
Ok(crate::opt14::types::ArchetypeConstraint::CCodeReference(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
))
}
Some("C_COMPLEX_OBJECT") => {
Ok(crate::opt14::types::ArchetypeConstraint::CComplexObject(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
))
}
Some("C_DEFINED_OBJECT") => {
Ok(crate::opt14::types::ArchetypeConstraint::CDefinedObject(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
))
}
Some("C_DV_ORDINAL") => Ok(crate::opt14::types::ArchetypeConstraint::CDvOrdinal(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_DV_QUANTITY") => Ok(crate::opt14::types::ArchetypeConstraint::CDvQuantity(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_DV_STATE") => Ok(crate::opt14::types::ArchetypeConstraint::CDvState(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_MULTIPLE_ATTRIBUTE") => Ok(
crate::opt14::types::ArchetypeConstraint::CMultipleAttribute(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
),
),
Some("C_PRIMITIVE_OBJECT") => {
Ok(crate::opt14::types::ArchetypeConstraint::CPrimitiveObject(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
))
}
Some("C_SINGLE_ATTRIBUTE") => {
Ok(crate::opt14::types::ArchetypeConstraint::CSingleAttribute(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
))
}
Some("T_COMPLEX_OBJECT") => {
Ok(crate::opt14::types::ArchetypeConstraint::TComplexObject(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
))
}
None => Err(crate::xml::runtime::XmlError::Parse(
"ArchetypeConstraint: missing xsi:type".into(),
)),
Some(other) => Err(crate::xml::runtime::XmlError::Parse(format!(
"ArchetypeConstraint: unknown xsi:type {other}: the ITS-XML OPT 1.4 schemas (Template.xsd, OpenehrProfile.xsd, Archetype.xsd) define no ARCHETYPE_CONSTRAINT subtype of that name"
))),
}
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::ArchetypeInternalRef {
fn xml_type_name(&self) -> &'static str {
"ARCHETYPE_INTERNAL_REF"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "ARCHETYPE_INTERNAL_REF" {
__attrs.push(("xsi:type", "ARCHETYPE_INTERNAL_REF".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.rm_type_name.write_xml(w, "rm_type_name", Some(""))?;
self.occurrences
.write_xml(w, "occurrences", Some("IntervalOfInteger"))?;
self.node_id.write_xml(w, "node_id", Some(""))?;
self.target_path.write_xml(w, "target_path", Some(""))?;
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::ArchetypeInternalRef {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __rm_type_name = None;
let mut __occurrences = None;
let mut __node_id = None;
let mut __target_path = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"rm_type_name" => {
__rm_type_name =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"occurrences" => {
__occurrences = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"node_id" => {
__node_id = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"target_path" => {
__target_path = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "ARCHETYPE_INTERNAL_REF".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::ArchetypeInternalRef {
rm_type_name: __rm_type_name.unwrap_or(String::new()),
occurrences: __occurrences.unwrap_or(crate::opt14::types::Intervalofinteger {
lower_included: Some(true),
upper_included: Some(true),
lower_unbounded: false,
upper_unbounded: false,
lower: Some(0),
upper: Some(1),
}),
node_id: __node_id.unwrap_or(String::new()),
target_path: __target_path
.ok_or_else(|| reader.missing_child("ARCHETYPE_INTERNAL_REF", "target_path"))?,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::ArchetypeOntology {
fn xml_type_name(&self) -> &'static str {
"ARCHETYPE_ONTOLOGY"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "ARCHETYPE_ONTOLOGY" {
__attrs.push(("xsi:type", "ARCHETYPE_ONTOLOGY".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
for v in &self.term_definitions {
v.write_xml(w, "term_definitions", Some("CodeDefinitionSet"))?;
}
for v in &self.constraint_definitions {
v.write_xml(w, "constraint_definitions", Some("CodeDefinitionSet"))?;
}
for v in &self.term_bindings {
v.write_xml(w, "term_bindings", Some("TermBindingSet"))?;
}
for v in &self.constraint_bindings {
v.write_xml(w, "constraint_bindings", Some("ConstraintBindingSet"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::ArchetypeOntology {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __term_definitions = Vec::new();
let mut __constraint_definitions = Vec::new();
let mut __term_bindings = Vec::new();
let mut __constraint_bindings = Vec::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"term_definitions" => {
__term_definitions
.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"constraint_definitions" => {
__constraint_definitions
.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"term_bindings" => {
__term_bindings.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"constraint_bindings" => {
__constraint_bindings
.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "ARCHETYPE_ONTOLOGY".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::ArchetypeOntology {
term_definitions: __term_definitions,
constraint_definitions: __constraint_definitions,
term_bindings: __term_bindings,
constraint_bindings: __constraint_bindings,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::ArchetypeSlot {
fn xml_type_name(&self) -> &'static str {
"ARCHETYPE_SLOT"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "ARCHETYPE_SLOT" {
__attrs.push(("xsi:type", "ARCHETYPE_SLOT".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.rm_type_name.write_xml(w, "rm_type_name", Some(""))?;
self.occurrences
.write_xml(w, "occurrences", Some("IntervalOfInteger"))?;
self.node_id.write_xml(w, "node_id", Some(""))?;
for v in &self.includes {
v.write_xml(w, "includes", Some("ASSERTION"))?;
}
for v in &self.excludes {
v.write_xml(w, "excludes", Some("ASSERTION"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::ArchetypeSlot {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __rm_type_name = None;
let mut __occurrences = None;
let mut __node_id = None;
let mut __includes = Vec::new();
let mut __excludes = Vec::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"rm_type_name" => {
__rm_type_name =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"occurrences" => {
__occurrences = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"node_id" => {
__node_id = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"includes" => {
__includes.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"excludes" => {
__excludes.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "ARCHETYPE_SLOT".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::ArchetypeSlot {
rm_type_name: __rm_type_name.unwrap_or(String::new()),
occurrences: __occurrences.unwrap_or(crate::opt14::types::Intervalofinteger {
lower_included: Some(true),
upper_included: Some(true),
lower_unbounded: false,
upper_unbounded: false,
lower: Some(0),
upper: Some(1),
}),
node_id: __node_id.unwrap_or(String::new()),
includes: __includes,
excludes: __excludes,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::ArchetypeTerm {
fn xml_type_name(&self) -> &'static str {
"ARCHETYPE_TERM"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "ARCHETYPE_TERM" {
__attrs.push(("xsi:type", "ARCHETYPE_TERM".to_string()));
}
}
__attrs.push(("code", self.code.to_string()));
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
for (k, v) in &self.items {
w.write_kv_element("items", k, v)?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::ArchetypeTerm {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __items = indexmap::IndexMap::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"items" => {
let __k = __c
.attr("id")
.ok_or_else(|| reader.missing_attribute("StringDictionaryItem", "id"))?
.to_string();
let __v: String = crate::xml::runtime::FromXml::from_xml(reader, &__c)?;
__items.insert(__k, __v);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "ARCHETYPE_TERM".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::ArchetypeTerm {
code: start
.attr("code")
.ok_or_else(|| reader.missing_attribute("ARCHETYPE_TERM", "code"))?
.to_string(),
items: __items,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::Assertion {
fn xml_type_name(&self) -> &'static str {
"ASSERTION"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "ASSERTION" {
__attrs.push(("xsi:type", "ASSERTION".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
if let Some(v) = &self.tag {
v.write_xml(w, "tag", Some(""))?;
}
if let Some(v) = &self.string_expression {
v.write_xml(w, "string_expression", Some(""))?;
}
self.expression
.write_xml(w, "expression", Some("EXPR_ITEM"))?;
for v in &self.variables {
v.write_xml(w, "variables", Some("ASSERTION_VARIABLE"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::Assertion {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __tag = None;
let mut __string_expression = None;
let mut __expression = None;
let mut __variables = Vec::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"tag" => {
__tag = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"string_expression" => {
__string_expression =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"expression" => {
__expression = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"variables" => {
__variables.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "ASSERTION".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::Assertion {
tag: __tag,
string_expression: __string_expression,
expression: __expression
.ok_or_else(|| reader.missing_child("ASSERTION", "expression"))?,
variables: __variables,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::AssertionVariable {
fn xml_type_name(&self) -> &'static str {
"ASSERTION_VARIABLE"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "ASSERTION_VARIABLE" {
__attrs.push(("xsi:type", "ASSERTION_VARIABLE".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.name.write_xml(w, "name", Some(""))?;
self.definition.write_xml(w, "definition", Some(""))?;
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::AssertionVariable {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __name = None;
let mut __definition = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"name" => {
__name = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"definition" => {
__definition = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "ASSERTION_VARIABLE".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::AssertionVariable {
name: __name.ok_or_else(|| reader.missing_child("ASSERTION_VARIABLE", "name"))?,
definition: __definition
.ok_or_else(|| reader.missing_child("ASSERTION_VARIABLE", "definition"))?,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::AuthoredResource {
fn xml_type_name(&self) -> &'static str {
match self {
crate::opt14::types::AuthoredResource::Archetype(x) => x.xml_type_name(),
}
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
match self {
crate::opt14::types::AuthoredResource::Archetype(x) => x.write_xml(w, tag, declared),
}
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::AuthoredResource {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
match start.xsi_type() {
Some("ARCHETYPE") => Ok(crate::opt14::types::AuthoredResource::Archetype(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
None => Err(crate::xml::runtime::XmlError::Parse(
"AuthoredResource: missing xsi:type".into(),
)),
Some(other) => Err(crate::xml::runtime::XmlError::Parse(format!(
"AuthoredResource: unknown xsi:type {other}: the ITS-XML OPT 1.4 schemas (Template.xsd, OpenehrProfile.xsd, Archetype.xsd) define no AUTHORED_RESOURCE subtype of that name"
))),
}
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::Cardinality {
fn xml_type_name(&self) -> &'static str {
"CARDINALITY"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "CARDINALITY" {
__attrs.push(("xsi:type", "CARDINALITY".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.is_ordered.write_xml(w, "is_ordered", Some(""))?;
self.is_unique.write_xml(w, "is_unique", Some(""))?;
self.interval
.write_xml(w, "interval", Some("IntervalOfInteger"))?;
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::Cardinality {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __is_ordered = None;
let mut __is_unique = None;
let mut __interval = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"is_ordered" => {
__is_ordered = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"is_unique" => {
__is_unique = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"interval" => {
__interval = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "CARDINALITY".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::Cardinality {
is_ordered: __is_ordered.unwrap_or(false),
is_unique: __is_unique.unwrap_or(false),
interval: __interval.ok_or_else(|| reader.missing_child("CARDINALITY", "interval"))?,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::ConstraintBindingItem {
fn xml_type_name(&self) -> &'static str {
"CONSTRAINT_BINDING_ITEM"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "CONSTRAINT_BINDING_ITEM" {
__attrs.push(("xsi:type", "CONSTRAINT_BINDING_ITEM".to_string()));
}
}
__attrs.push(("code", self.code.to_string()));
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.value.write_xml(w, "value", Some(""))?;
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::ConstraintBindingItem {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __value = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"value" => {
__value = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "CONSTRAINT_BINDING_ITEM".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::ConstraintBindingItem {
code: start
.attr("code")
.ok_or_else(|| reader.missing_attribute("CONSTRAINT_BINDING_ITEM", "code"))?
.to_string(),
value: __value
.ok_or_else(|| reader.missing_child("CONSTRAINT_BINDING_ITEM", "value"))?,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::ConstraintRef {
fn xml_type_name(&self) -> &'static str {
"CONSTRAINT_REF"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "CONSTRAINT_REF" {
__attrs.push(("xsi:type", "CONSTRAINT_REF".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.rm_type_name.write_xml(w, "rm_type_name", Some(""))?;
self.occurrences
.write_xml(w, "occurrences", Some("IntervalOfInteger"))?;
self.node_id.write_xml(w, "node_id", Some(""))?;
self.reference.write_xml(w, "reference", Some(""))?;
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::ConstraintRef {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __rm_type_name = None;
let mut __occurrences = None;
let mut __node_id = None;
let mut __reference = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"rm_type_name" => {
__rm_type_name =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"occurrences" => {
__occurrences = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"node_id" => {
__node_id = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"reference" => {
__reference = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "CONSTRAINT_REF".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::ConstraintRef {
rm_type_name: __rm_type_name.unwrap_or(String::new()),
occurrences: __occurrences.unwrap_or(crate::opt14::types::Intervalofinteger {
lower_included: Some(true),
upper_included: Some(true),
lower_unbounded: false,
upper_unbounded: false,
lower: Some(0),
upper: Some(1),
}),
node_id: __node_id.unwrap_or(String::new()),
reference: __reference
.ok_or_else(|| reader.missing_child("CONSTRAINT_REF", "reference"))?,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CArchetypeRoot {
fn xml_type_name(&self) -> &'static str {
"C_ARCHETYPE_ROOT"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_ARCHETYPE_ROOT" {
__attrs.push(("xsi:type", "C_ARCHETYPE_ROOT".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.rm_type_name.write_xml(w, "rm_type_name", Some(""))?;
self.occurrences
.write_xml(w, "occurrences", Some("IntervalOfInteger"))?;
self.node_id.write_xml(w, "node_id", Some(""))?;
for v in &self.attributes {
v.write_xml(w, "attributes", Some("C_ATTRIBUTE"))?;
}
self.archetype_id
.write_xml(w, "archetype_id", Some("ARCHETYPE_ID"))?;
if let Some(v) = &self.template_id {
v.write_xml(w, "template_id", Some("TEMPLATE_ID"))?;
}
for v in &self.term_definitions {
v.write_xml(w, "term_definitions", Some("ARCHETYPE_TERM"))?;
}
for v in &self.term_bindings {
v.write_xml(w, "term_bindings", Some("TermBindingSet"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CArchetypeRoot {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __rm_type_name = None;
let mut __occurrences = None;
let mut __node_id = None;
let mut __attributes = Vec::new();
let mut __archetype_id = None;
let mut __template_id = None;
let mut __term_definitions = Vec::new();
let mut __term_bindings = Vec::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"rm_type_name" => {
__rm_type_name =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"occurrences" => {
__occurrences = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"node_id" => {
__node_id = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"attributes" => {
__attributes.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"archetype_id" => {
__archetype_id =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"template_id" => {
__template_id = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"term_definitions" => {
__term_definitions
.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"term_bindings" => {
__term_bindings.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_ARCHETYPE_ROOT".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CArchetypeRoot {
rm_type_name: __rm_type_name.unwrap_or(String::new()),
occurrences: __occurrences.unwrap_or(crate::opt14::types::Intervalofinteger {
lower_included: Some(true),
upper_included: Some(true),
lower_unbounded: false,
upper_unbounded: false,
lower: Some(0),
upper: Some(1),
}),
node_id: __node_id.unwrap_or(String::new()),
attributes: __attributes,
archetype_id: __archetype_id
.ok_or_else(|| reader.missing_child("C_ARCHETYPE_ROOT", "archetype_id"))?,
template_id: __template_id,
term_definitions: __term_definitions,
term_bindings: __term_bindings,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CAttribute {
fn xml_type_name(&self) -> &'static str {
match self {
crate::opt14::types::CAttribute::CMultipleAttribute(x) => x.xml_type_name(),
crate::opt14::types::CAttribute::CSingleAttribute(x) => x.xml_type_name(),
}
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
match self {
crate::opt14::types::CAttribute::CMultipleAttribute(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CAttribute::CSingleAttribute(x) => x.write_xml(w, tag, declared),
}
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CAttribute {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
match start.xsi_type() {
Some("C_MULTIPLE_ATTRIBUTE") => {
Ok(crate::opt14::types::CAttribute::CMultipleAttribute(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
))
}
Some("C_SINGLE_ATTRIBUTE") => Ok(crate::opt14::types::CAttribute::CSingleAttribute(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
None => Err(crate::xml::runtime::XmlError::Parse(
"CAttribute: missing xsi:type".into(),
)),
Some(other) => Err(crate::xml::runtime::XmlError::Parse(format!(
"CAttribute: unknown xsi:type {other}: the ITS-XML OPT 1.4 schemas (Template.xsd, OpenehrProfile.xsd, Archetype.xsd) define no C_ATTRIBUTE subtype of that name"
))),
}
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CBoolean {
fn xml_type_name(&self) -> &'static str {
"C_BOOLEAN"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_BOOLEAN" {
__attrs.push(("xsi:type", "C_BOOLEAN".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.true_valid.write_xml(w, "true_valid", Some(""))?;
self.false_valid.write_xml(w, "false_valid", Some(""))?;
if let Some(v) = &self.assumed_value {
v.write_xml(w, "assumed_value", Some(""))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CBoolean {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __true_valid = None;
let mut __false_valid = None;
let mut __assumed_value = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"true_valid" => {
__true_valid = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"false_valid" => {
__false_valid = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"assumed_value" => {
__assumed_value =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_BOOLEAN".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CBoolean {
true_valid: __true_valid.unwrap_or(false),
false_valid: __false_valid.unwrap_or(false),
assumed_value: __assumed_value,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CCodePhrase {
fn xml_type_name(&self) -> &'static str {
"C_CODE_PHRASE"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_CODE_PHRASE" {
__attrs.push(("xsi:type", "C_CODE_PHRASE".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.rm_type_name.write_xml(w, "rm_type_name", Some(""))?;
self.occurrences
.write_xml(w, "occurrences", Some("IntervalOfInteger"))?;
self.node_id.write_xml(w, "node_id", Some(""))?;
if let Some(v) = &self.assumed_value {
v.write_xml(w, "assumed_value", Some("CODE_PHRASE"))?;
}
if let Some(v) = &self.terminology_id {
v.write_xml(w, "terminology_id", Some("TERMINOLOGY_ID"))?;
}
for v in &self.code_list {
v.write_xml(w, "code_list", Some(""))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CCodePhrase {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __rm_type_name = None;
let mut __occurrences = None;
let mut __node_id = None;
let mut __assumed_value = None;
let mut __terminology_id = None;
let mut __code_list = Vec::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"rm_type_name" => {
__rm_type_name =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"occurrences" => {
__occurrences = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"node_id" => {
__node_id = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"assumed_value" => {
__assumed_value =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"terminology_id" => {
__terminology_id =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"code_list" => {
__code_list.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_CODE_PHRASE".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CCodePhrase {
rm_type_name: __rm_type_name.unwrap_or(String::new()),
occurrences: __occurrences.unwrap_or(crate::opt14::types::Intervalofinteger {
lower_included: Some(true),
upper_included: Some(true),
lower_unbounded: false,
upper_unbounded: false,
lower: Some(0),
upper: Some(1),
}),
node_id: __node_id.unwrap_or(String::new()),
assumed_value: __assumed_value,
terminology_id: __terminology_id,
code_list: __code_list,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CCodeReference {
fn xml_type_name(&self) -> &'static str {
"C_CODE_REFERENCE"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_CODE_REFERENCE" {
__attrs.push(("xsi:type", "C_CODE_REFERENCE".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.rm_type_name.write_xml(w, "rm_type_name", Some(""))?;
self.occurrences
.write_xml(w, "occurrences", Some("IntervalOfInteger"))?;
self.node_id.write_xml(w, "node_id", Some(""))?;
if let Some(v) = &self.assumed_value {
v.write_xml(w, "assumed_value", Some("CODE_PHRASE"))?;
}
if let Some(v) = &self.terminology_id {
v.write_xml(w, "terminology_id", Some("TERMINOLOGY_ID"))?;
}
for v in &self.code_list {
v.write_xml(w, "code_list", Some(""))?;
}
self.referenceSetUri
.write_xml(w, "referenceSetUri", Some(""))?;
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CCodeReference {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __rm_type_name = None;
let mut __occurrences = None;
let mut __node_id = None;
let mut __assumed_value = None;
let mut __terminology_id = None;
let mut __code_list = Vec::new();
let mut __referenceSetUri = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"rm_type_name" => {
__rm_type_name =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"occurrences" => {
__occurrences = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"node_id" => {
__node_id = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"assumed_value" => {
__assumed_value =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"terminology_id" => {
__terminology_id =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"code_list" => {
__code_list.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"referenceSetUri" => {
__referenceSetUri =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_CODE_REFERENCE".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CCodeReference {
rm_type_name: __rm_type_name.unwrap_or(String::new()),
occurrences: __occurrences.unwrap_or(crate::opt14::types::Intervalofinteger {
lower_included: Some(true),
upper_included: Some(true),
lower_unbounded: false,
upper_unbounded: false,
lower: Some(0),
upper: Some(1),
}),
node_id: __node_id.unwrap_or(String::new()),
assumed_value: __assumed_value,
terminology_id: __terminology_id,
code_list: __code_list,
referenceSetUri: __referenceSetUri
.ok_or_else(|| reader.missing_child("C_CODE_REFERENCE", "referenceSetUri"))?,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CComplexObject {
fn xml_type_name(&self) -> &'static str {
"C_COMPLEX_OBJECT"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_COMPLEX_OBJECT" {
__attrs.push(("xsi:type", "C_COMPLEX_OBJECT".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.rm_type_name.write_xml(w, "rm_type_name", Some(""))?;
self.occurrences
.write_xml(w, "occurrences", Some("IntervalOfInteger"))?;
self.node_id.write_xml(w, "node_id", Some(""))?;
for v in &self.attributes {
v.write_xml(w, "attributes", Some("C_ATTRIBUTE"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CComplexObject {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __rm_type_name = None;
let mut __occurrences = None;
let mut __node_id = None;
let mut __attributes = Vec::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"rm_type_name" => {
__rm_type_name =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"occurrences" => {
__occurrences = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"node_id" => {
__node_id = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"attributes" => {
__attributes.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_COMPLEX_OBJECT".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CComplexObject {
rm_type_name: __rm_type_name.unwrap_or(String::new()),
occurrences: __occurrences.unwrap_or(crate::opt14::types::Intervalofinteger {
lower_included: Some(true),
upper_included: Some(true),
lower_unbounded: false,
upper_unbounded: false,
lower: Some(0),
upper: Some(1),
}),
node_id: __node_id.unwrap_or(String::new()),
attributes: __attributes,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CDate {
fn xml_type_name(&self) -> &'static str {
"C_DATE"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_DATE" {
__attrs.push(("xsi:type", "C_DATE".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
if let Some(v) = &self.pattern {
v.write_xml(w, "pattern", Some(""))?;
}
if let Some(v) = &self.timezone_validity {
v.write_xml(w, "timezone_validity", Some(""))?;
}
if let Some(v) = &self.range {
v.write_xml(w, "range", Some("IntervalOfDate"))?;
}
if let Some(v) = &self.assumed_value {
v.write_xml(w, "assumed_value", Some(""))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CDate {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __pattern = None;
let mut __timezone_validity = None;
let mut __range = None;
let mut __assumed_value = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"pattern" => {
__pattern = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"timezone_validity" => {
__timezone_validity =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"range" => {
__range = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"assumed_value" => {
__assumed_value =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_DATE".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CDate {
pattern: __pattern,
timezone_validity: __timezone_validity,
range: __range,
assumed_value: __assumed_value,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CDateTime {
fn xml_type_name(&self) -> &'static str {
"C_DATE_TIME"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_DATE_TIME" {
__attrs.push(("xsi:type", "C_DATE_TIME".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
if let Some(v) = &self.pattern {
v.write_xml(w, "pattern", Some(""))?;
}
if let Some(v) = &self.timezone_validity {
v.write_xml(w, "timezone_validity", Some(""))?;
}
if let Some(v) = &self.range {
v.write_xml(w, "range", Some("IntervalOfDateTime"))?;
}
if let Some(v) = &self.assumed_value {
v.write_xml(w, "assumed_value", Some(""))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CDateTime {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __pattern = None;
let mut __timezone_validity = None;
let mut __range = None;
let mut __assumed_value = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"pattern" => {
__pattern = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"timezone_validity" => {
__timezone_validity =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"range" => {
__range = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"assumed_value" => {
__assumed_value =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_DATE_TIME".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CDateTime {
pattern: __pattern,
timezone_validity: __timezone_validity,
range: __range,
assumed_value: __assumed_value,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CDefinedObject {
fn xml_type_name(&self) -> &'static str {
"C_DEFINED_OBJECT"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_DEFINED_OBJECT" {
__attrs.push(("xsi:type", "C_DEFINED_OBJECT".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.rm_type_name.write_xml(w, "rm_type_name", Some(""))?;
self.occurrences
.write_xml(w, "occurrences", Some("IntervalOfInteger"))?;
self.node_id.write_xml(w, "node_id", Some(""))?;
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CDefinedObject {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __rm_type_name = None;
let mut __occurrences = None;
let mut __node_id = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"rm_type_name" => {
__rm_type_name =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"occurrences" => {
__occurrences = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"node_id" => {
__node_id = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_DEFINED_OBJECT".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CDefinedObject {
rm_type_name: __rm_type_name.unwrap_or(String::new()),
occurrences: __occurrences.unwrap_or(crate::opt14::types::Intervalofinteger {
lower_included: Some(true),
upper_included: Some(true),
lower_unbounded: false,
upper_unbounded: false,
lower: Some(0),
upper: Some(1),
}),
node_id: __node_id.unwrap_or(String::new()),
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CDomainType {
fn xml_type_name(&self) -> &'static str {
match self {
crate::opt14::types::CDomainType::CCodePhrase(x) => x.xml_type_name(),
crate::opt14::types::CDomainType::CCodeReference(x) => x.xml_type_name(),
crate::opt14::types::CDomainType::CDvOrdinal(x) => x.xml_type_name(),
crate::opt14::types::CDomainType::CDvQuantity(x) => x.xml_type_name(),
crate::opt14::types::CDomainType::CDvState(x) => x.xml_type_name(),
}
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
match self {
crate::opt14::types::CDomainType::CCodePhrase(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CDomainType::CCodeReference(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CDomainType::CDvOrdinal(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CDomainType::CDvQuantity(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CDomainType::CDvState(x) => x.write_xml(w, tag, declared),
}
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CDomainType {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
match start.xsi_type() {
Some("C_CODE_PHRASE") => Ok(crate::opt14::types::CDomainType::CCodePhrase(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_CODE_REFERENCE") => Ok(crate::opt14::types::CDomainType::CCodeReference(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_DV_ORDINAL") => Ok(crate::opt14::types::CDomainType::CDvOrdinal(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_DV_QUANTITY") => Ok(crate::opt14::types::CDomainType::CDvQuantity(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_DV_STATE") => Ok(crate::opt14::types::CDomainType::CDvState(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
None => Err(crate::xml::runtime::XmlError::Parse(
"CDomainType: missing xsi:type".into(),
)),
Some(other) => Err(crate::xml::runtime::XmlError::Parse(format!(
"CDomainType: unknown xsi:type {other}: the ITS-XML OPT 1.4 schemas (Template.xsd, OpenehrProfile.xsd, Archetype.xsd) define no C_DOMAIN_TYPE subtype of that name"
))),
}
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CDuration {
fn xml_type_name(&self) -> &'static str {
"C_DURATION"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_DURATION" {
__attrs.push(("xsi:type", "C_DURATION".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
if let Some(v) = &self.pattern {
v.write_xml(w, "pattern", Some(""))?;
}
if let Some(v) = &self.range {
v.write_xml(w, "range", Some("IntervalOfDuration"))?;
}
if let Some(v) = &self.assumed_value {
v.write_xml(w, "assumed_value", Some(""))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CDuration {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __pattern = None;
let mut __range = None;
let mut __assumed_value = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"pattern" => {
__pattern = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"range" => {
__range = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"assumed_value" => {
__assumed_value =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_DURATION".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CDuration {
pattern: __pattern,
range: __range,
assumed_value: __assumed_value,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CDvOrdinal {
fn xml_type_name(&self) -> &'static str {
"C_DV_ORDINAL"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_DV_ORDINAL" {
__attrs.push(("xsi:type", "C_DV_ORDINAL".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.rm_type_name.write_xml(w, "rm_type_name", Some(""))?;
self.occurrences
.write_xml(w, "occurrences", Some("IntervalOfInteger"))?;
self.node_id.write_xml(w, "node_id", Some(""))?;
if let Some(v) = &self.assumed_value {
v.write_xml(w, "assumed_value", Some("DV_ORDINAL"))?;
}
for v in &self.list {
v.write_xml(w, "list", Some("DV_ORDINAL"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CDvOrdinal {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __rm_type_name = None;
let mut __occurrences = None;
let mut __node_id = None;
let mut __assumed_value = None;
let mut __list = Vec::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"rm_type_name" => {
__rm_type_name =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"occurrences" => {
__occurrences = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"node_id" => {
__node_id = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"assumed_value" => {
__assumed_value =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"list" => {
__list.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_DV_ORDINAL".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CDvOrdinal {
rm_type_name: __rm_type_name.unwrap_or(String::new()),
occurrences: __occurrences.unwrap_or(crate::opt14::types::Intervalofinteger {
lower_included: Some(true),
upper_included: Some(true),
lower_unbounded: false,
upper_unbounded: false,
lower: Some(0),
upper: Some(1),
}),
node_id: __node_id.unwrap_or(String::new()),
assumed_value: __assumed_value,
list: __list,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CDvQuantity {
fn xml_type_name(&self) -> &'static str {
"C_DV_QUANTITY"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_DV_QUANTITY" {
__attrs.push(("xsi:type", "C_DV_QUANTITY".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.rm_type_name.write_xml(w, "rm_type_name", Some(""))?;
self.occurrences
.write_xml(w, "occurrences", Some("IntervalOfInteger"))?;
self.node_id.write_xml(w, "node_id", Some(""))?;
if let Some(v) = &self.assumed_value {
v.write_xml(w, "assumed_value", Some("DV_QUANTITY"))?;
}
if let Some(v) = &self.property {
v.write_xml(w, "property", Some("CODE_PHRASE"))?;
}
for v in &self.list {
v.write_xml(w, "list", Some("C_QUANTITY_ITEM"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CDvQuantity {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __rm_type_name = None;
let mut __occurrences = None;
let mut __node_id = None;
let mut __assumed_value = None;
let mut __property = None;
let mut __list = Vec::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"rm_type_name" => {
__rm_type_name =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"occurrences" => {
__occurrences = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"node_id" => {
__node_id = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"assumed_value" => {
__assumed_value =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"property" => {
__property = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"list" => {
__list.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_DV_QUANTITY".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CDvQuantity {
rm_type_name: __rm_type_name.unwrap_or(String::new()),
occurrences: __occurrences.unwrap_or(crate::opt14::types::Intervalofinteger {
lower_included: Some(true),
upper_included: Some(true),
lower_unbounded: false,
upper_unbounded: false,
lower: Some(0),
upper: Some(1),
}),
node_id: __node_id.unwrap_or(String::new()),
assumed_value: __assumed_value,
property: __property,
list: __list,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CDvState {
fn xml_type_name(&self) -> &'static str {
"C_DV_STATE"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_DV_STATE" {
__attrs.push(("xsi:type", "C_DV_STATE".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.rm_type_name.write_xml(w, "rm_type_name", Some(""))?;
self.occurrences
.write_xml(w, "occurrences", Some("IntervalOfInteger"))?;
self.node_id.write_xml(w, "node_id", Some(""))?;
if let Some(v) = &self.assumed_value {
v.write_xml(w, "assumed_value", Some("DV_STATE"))?;
}
self.value.write_xml(w, "value", Some("STATE_MACHINE"))?;
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CDvState {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __rm_type_name = None;
let mut __occurrences = None;
let mut __node_id = None;
let mut __assumed_value = None;
let mut __value = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"rm_type_name" => {
__rm_type_name =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"occurrences" => {
__occurrences = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"node_id" => {
__node_id = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"assumed_value" => {
__assumed_value =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"value" => {
__value = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_DV_STATE".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CDvState {
rm_type_name: __rm_type_name.unwrap_or(String::new()),
occurrences: __occurrences.unwrap_or(crate::opt14::types::Intervalofinteger {
lower_included: Some(true),
upper_included: Some(true),
lower_unbounded: false,
upper_unbounded: false,
lower: Some(0),
upper: Some(1),
}),
node_id: __node_id.unwrap_or(String::new()),
assumed_value: __assumed_value,
value: __value.ok_or_else(|| reader.missing_child("C_DV_STATE", "value"))?,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CInteger {
fn xml_type_name(&self) -> &'static str {
"C_INTEGER"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_INTEGER" {
__attrs.push(("xsi:type", "C_INTEGER".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
for v in &self.list {
v.write_xml(w, "list", Some(""))?;
}
if let Some(v) = &self.range {
v.write_xml(w, "range", Some("IntervalOfInteger"))?;
}
if let Some(v) = &self.assumed_value {
v.write_xml(w, "assumed_value", Some(""))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CInteger {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __list = Vec::new();
let mut __range = None;
let mut __assumed_value = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"list" => {
__list.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"range" => {
__range = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"assumed_value" => {
__assumed_value =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_INTEGER".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CInteger {
list: __list,
range: __range,
assumed_value: __assumed_value,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CMultipleAttribute {
fn xml_type_name(&self) -> &'static str {
"C_MULTIPLE_ATTRIBUTE"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_MULTIPLE_ATTRIBUTE" {
__attrs.push(("xsi:type", "C_MULTIPLE_ATTRIBUTE".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.rm_attribute_name
.write_xml(w, "rm_attribute_name", Some(""))?;
self.existence
.write_xml(w, "existence", Some("IntervalOfInteger"))?;
for v in &self.children {
v.write_xml(w, "children", Some("C_OBJECT"))?;
}
self.cardinality
.write_xml(w, "cardinality", Some("CARDINALITY"))?;
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CMultipleAttribute {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __rm_attribute_name = None;
let mut __existence = None;
let mut __children = Vec::new();
let mut __cardinality = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"rm_attribute_name" => {
__rm_attribute_name =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"existence" => {
__existence = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"children" => {
__children.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"cardinality" => {
__cardinality = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"match_negated" => crate::xml::runtime::read_false_extension(
reader,
&__c,
"C_MULTIPLE_ATTRIBUTE",
)?,
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_MULTIPLE_ATTRIBUTE".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CMultipleAttribute {
rm_attribute_name: __rm_attribute_name
.ok_or_else(|| reader.missing_child("C_MULTIPLE_ATTRIBUTE", "rm_attribute_name"))?,
existence: __existence.unwrap_or(crate::opt14::types::Intervalofinteger {
lower_included: Some(true),
upper_included: Some(true),
lower_unbounded: false,
upper_unbounded: false,
lower: Some(0),
upper: Some(1),
}),
children: __children,
cardinality: __cardinality
.ok_or_else(|| reader.missing_child("C_MULTIPLE_ATTRIBUTE", "cardinality"))?,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CObject {
fn xml_type_name(&self) -> &'static str {
match self {
crate::opt14::types::CObject::ArchetypeInternalRef(x) => x.xml_type_name(),
crate::opt14::types::CObject::ArchetypeSlot(x) => x.xml_type_name(),
crate::opt14::types::CObject::ConstraintRef(x) => x.xml_type_name(),
crate::opt14::types::CObject::CArchetypeRoot(x) => x.xml_type_name(),
crate::opt14::types::CObject::CCodePhrase(x) => x.xml_type_name(),
crate::opt14::types::CObject::CCodeReference(x) => x.xml_type_name(),
crate::opt14::types::CObject::CComplexObject(x) => x.xml_type_name(),
crate::opt14::types::CObject::CDefinedObject(x) => x.xml_type_name(),
crate::opt14::types::CObject::CDvOrdinal(x) => x.xml_type_name(),
crate::opt14::types::CObject::CDvQuantity(x) => x.xml_type_name(),
crate::opt14::types::CObject::CDvState(x) => x.xml_type_name(),
crate::opt14::types::CObject::CPrimitiveObject(x) => x.xml_type_name(),
crate::opt14::types::CObject::TComplexObject(x) => x.xml_type_name(),
}
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
match self {
crate::opt14::types::CObject::ArchetypeInternalRef(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CObject::ArchetypeSlot(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CObject::ConstraintRef(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CObject::CArchetypeRoot(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CObject::CCodePhrase(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CObject::CCodeReference(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CObject::CComplexObject(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CObject::CDefinedObject(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CObject::CDvOrdinal(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CObject::CDvQuantity(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CObject::CDvState(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CObject::CPrimitiveObject(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CObject::TComplexObject(x) => x.write_xml(w, tag, declared),
}
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CObject {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
match start.xsi_type() {
Some("ARCHETYPE_INTERNAL_REF") => {
Ok(crate::opt14::types::CObject::ArchetypeInternalRef(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
))
}
Some("ARCHETYPE_SLOT") => Ok(crate::opt14::types::CObject::ArchetypeSlot(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("CONSTRAINT_REF") => Ok(crate::opt14::types::CObject::ConstraintRef(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_ARCHETYPE_ROOT") => Ok(crate::opt14::types::CObject::CArchetypeRoot(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_CODE_PHRASE") => Ok(crate::opt14::types::CObject::CCodePhrase(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_CODE_REFERENCE") => Ok(crate::opt14::types::CObject::CCodeReference(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_COMPLEX_OBJECT") => Ok(crate::opt14::types::CObject::CComplexObject(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_DEFINED_OBJECT") => Ok(crate::opt14::types::CObject::CDefinedObject(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_DV_ORDINAL") => Ok(crate::opt14::types::CObject::CDvOrdinal(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_DV_QUANTITY") => Ok(crate::opt14::types::CObject::CDvQuantity(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_DV_STATE") => Ok(crate::opt14::types::CObject::CDvState(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_PRIMITIVE_OBJECT") => Ok(crate::opt14::types::CObject::CPrimitiveObject(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("T_COMPLEX_OBJECT") => Ok(crate::opt14::types::CObject::TComplexObject(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
None => Err(crate::xml::runtime::XmlError::Parse(
"CObject: missing xsi:type".into(),
)),
Some(other) => Err(crate::xml::runtime::XmlError::Parse(format!(
"CObject: unknown xsi:type {other}: the ITS-XML OPT 1.4 schemas (Template.xsd, OpenehrProfile.xsd, Archetype.xsd) define no C_OBJECT subtype of that name"
))),
}
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CPrimitive {
fn xml_type_name(&self) -> &'static str {
match self {
crate::opt14::types::CPrimitive::CBoolean(x) => x.xml_type_name(),
crate::opt14::types::CPrimitive::CDate(x) => x.xml_type_name(),
crate::opt14::types::CPrimitive::CDateTime(x) => x.xml_type_name(),
crate::opt14::types::CPrimitive::CDuration(x) => x.xml_type_name(),
crate::opt14::types::CPrimitive::CInteger(x) => x.xml_type_name(),
crate::opt14::types::CPrimitive::CReal(x) => x.xml_type_name(),
crate::opt14::types::CPrimitive::CString(x) => x.xml_type_name(),
crate::opt14::types::CPrimitive::CTime(x) => x.xml_type_name(),
}
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
match self {
crate::opt14::types::CPrimitive::CBoolean(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CPrimitive::CDate(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CPrimitive::CDateTime(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CPrimitive::CDuration(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CPrimitive::CInteger(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CPrimitive::CReal(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CPrimitive::CString(x) => x.write_xml(w, tag, declared),
crate::opt14::types::CPrimitive::CTime(x) => x.write_xml(w, tag, declared),
}
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CPrimitive {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
match start.xsi_type() {
Some("C_BOOLEAN") => Ok(crate::opt14::types::CPrimitive::CBoolean(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_DATE") => Ok(crate::opt14::types::CPrimitive::CDate(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_DATE_TIME") => Ok(crate::opt14::types::CPrimitive::CDateTime(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_DURATION") => Ok(crate::opt14::types::CPrimitive::CDuration(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_INTEGER") => Ok(crate::opt14::types::CPrimitive::CInteger(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_REAL") => Ok(crate::opt14::types::CPrimitive::CReal(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_STRING") => Ok(crate::opt14::types::CPrimitive::CString(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("C_TIME") => Ok(crate::opt14::types::CPrimitive::CTime(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
None => Err(crate::xml::runtime::XmlError::Parse(
"CPrimitive: missing xsi:type".into(),
)),
Some(other) => Err(crate::xml::runtime::XmlError::Parse(format!(
"CPrimitive: unknown xsi:type {other}: the ITS-XML OPT 1.4 schemas (Template.xsd, OpenehrProfile.xsd, Archetype.xsd) define no C_PRIMITIVE subtype of that name"
))),
}
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CPrimitiveObject {
fn xml_type_name(&self) -> &'static str {
"C_PRIMITIVE_OBJECT"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_PRIMITIVE_OBJECT" {
__attrs.push(("xsi:type", "C_PRIMITIVE_OBJECT".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.rm_type_name.write_xml(w, "rm_type_name", Some(""))?;
self.occurrences
.write_xml(w, "occurrences", Some("IntervalOfInteger"))?;
self.node_id.write_xml(w, "node_id", Some(""))?;
if let Some(v) = &self.item {
v.write_xml(w, "item", Some("C_PRIMITIVE"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CPrimitiveObject {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __rm_type_name = None;
let mut __occurrences = None;
let mut __node_id = None;
let mut __item = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"rm_type_name" => {
__rm_type_name =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"occurrences" => {
__occurrences = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"node_id" => {
__node_id = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"item" => {
__item = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_PRIMITIVE_OBJECT".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CPrimitiveObject {
rm_type_name: __rm_type_name.unwrap_or(String::new()),
occurrences: __occurrences.unwrap_or(crate::opt14::types::Intervalofinteger {
lower_included: Some(true),
upper_included: Some(true),
lower_unbounded: false,
upper_unbounded: false,
lower: Some(0),
upper: Some(1),
}),
node_id: __node_id.unwrap_or(String::new()),
item: __item,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CQuantityItem {
fn xml_type_name(&self) -> &'static str {
"C_QUANTITY_ITEM"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_QUANTITY_ITEM" {
__attrs.push(("xsi:type", "C_QUANTITY_ITEM".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
if let Some(v) = &self.magnitude {
v.write_xml(w, "magnitude", Some("IntervalOfReal"))?;
}
if let Some(v) = &self.precision {
v.write_xml(w, "precision", Some("IntervalOfInteger"))?;
}
self.units.write_xml(w, "units", Some(""))?;
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CQuantityItem {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __magnitude = None;
let mut __precision = None;
let mut __units = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"magnitude" => {
__magnitude = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"precision" => {
__precision = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"units" => {
__units = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_QUANTITY_ITEM".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CQuantityItem {
magnitude: __magnitude,
precision: __precision,
units: __units.ok_or_else(|| reader.missing_child("C_QUANTITY_ITEM", "units"))?,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CReal {
fn xml_type_name(&self) -> &'static str {
"C_REAL"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_REAL" {
__attrs.push(("xsi:type", "C_REAL".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
for v in &self.list {
v.write_xml(w, "list", Some(""))?;
}
if let Some(v) = &self.range {
v.write_xml(w, "range", Some("IntervalOfReal"))?;
}
if let Some(v) = &self.assumed_value {
v.write_xml(w, "assumed_value", Some(""))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CReal {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __list = Vec::new();
let mut __range = None;
let mut __assumed_value = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"list" => {
__list.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"range" => {
__range = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"assumed_value" => {
__assumed_value =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_REAL".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CReal {
list: __list,
range: __range,
assumed_value: __assumed_value,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CSingleAttribute {
fn xml_type_name(&self) -> &'static str {
"C_SINGLE_ATTRIBUTE"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_SINGLE_ATTRIBUTE" {
__attrs.push(("xsi:type", "C_SINGLE_ATTRIBUTE".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.rm_attribute_name
.write_xml(w, "rm_attribute_name", Some(""))?;
self.existence
.write_xml(w, "existence", Some("IntervalOfInteger"))?;
for v in &self.children {
v.write_xml(w, "children", Some("C_OBJECT"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CSingleAttribute {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __rm_attribute_name = None;
let mut __existence = None;
let mut __children = Vec::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"rm_attribute_name" => {
__rm_attribute_name =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"existence" => {
__existence = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"children" => {
__children.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"match_negated" => crate::xml::runtime::read_false_extension(
reader,
&__c,
"C_SINGLE_ATTRIBUTE",
)?,
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_SINGLE_ATTRIBUTE".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CSingleAttribute {
rm_attribute_name: __rm_attribute_name
.ok_or_else(|| reader.missing_child("C_SINGLE_ATTRIBUTE", "rm_attribute_name"))?,
existence: __existence.unwrap_or(crate::opt14::types::Intervalofinteger {
lower_included: Some(true),
upper_included: Some(true),
lower_unbounded: false,
upper_unbounded: false,
lower: Some(0),
upper: Some(1),
}),
children: __children,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CString {
fn xml_type_name(&self) -> &'static str {
"C_STRING"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_STRING" {
__attrs.push(("xsi:type", "C_STRING".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
if let Some(v) = &self.pattern {
v.write_xml(w, "pattern", Some(""))?;
}
for v in &self.list {
v.write_xml(w, "list", Some(""))?;
}
if let Some(v) = &self.list_open {
v.write_xml(w, "list_open", Some(""))?;
}
if let Some(v) = &self.assumed_value {
v.write_xml(w, "assumed_value", Some(""))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CString {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __pattern = None;
let mut __list = Vec::new();
let mut __list_open = None;
let mut __assumed_value = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"pattern" => {
__pattern = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"list" => {
__list.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"list_open" => {
__list_open = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"assumed_value" => {
__assumed_value =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_STRING".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CString {
pattern: __pattern,
list: __list,
list_open: __list_open,
assumed_value: __assumed_value,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::CTime {
fn xml_type_name(&self) -> &'static str {
"C_TIME"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "C_TIME" {
__attrs.push(("xsi:type", "C_TIME".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
if let Some(v) = &self.pattern {
v.write_xml(w, "pattern", Some(""))?;
}
if let Some(v) = &self.timezone_validity {
v.write_xml(w, "timezone_validity", Some(""))?;
}
if let Some(v) = &self.range {
v.write_xml(w, "range", Some("IntervalOfTime"))?;
}
if let Some(v) = &self.assumed_value {
v.write_xml(w, "assumed_value", Some(""))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::CTime {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __pattern = None;
let mut __timezone_validity = None;
let mut __range = None;
let mut __assumed_value = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"pattern" => {
__pattern = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"timezone_validity" => {
__timezone_validity =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"range" => {
__range = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"assumed_value" => {
__assumed_value =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "C_TIME".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::CTime {
pattern: __pattern,
timezone_validity: __timezone_validity,
range: __range,
assumed_value: __assumed_value,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::Codedefinitionset {
fn xml_type_name(&self) -> &'static str {
"CodeDefinitionSet"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "CodeDefinitionSet" {
__attrs.push(("xsi:type", "CodeDefinitionSet".to_string()));
}
}
__attrs.push(("language", self.language.to_string()));
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
for v in &self.items {
v.write_xml(w, "items", Some("ARCHETYPE_TERM"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::Codedefinitionset {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __items = Vec::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"items" => {
__items.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "CodeDefinitionSet".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::Codedefinitionset {
language: start
.attr("language")
.ok_or_else(|| reader.missing_attribute("CodeDefinitionSet", "language"))?
.to_string(),
items: __items,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::Constraintbindingset {
fn xml_type_name(&self) -> &'static str {
"ConstraintBindingSet"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "ConstraintBindingSet" {
__attrs.push(("xsi:type", "ConstraintBindingSet".to_string()));
}
}
__attrs.push(("terminology", self.terminology.to_string()));
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
for v in &self.items {
v.write_xml(w, "items", Some("CONSTRAINT_BINDING_ITEM"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::Constraintbindingset {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __items = Vec::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"items" => {
__items.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "ConstraintBindingSet".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::Constraintbindingset {
terminology: start
.attr("terminology")
.ok_or_else(|| reader.missing_attribute("ConstraintBindingSet", "terminology"))?
.to_string(),
items: __items,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::ExprBinaryOperator {
fn xml_type_name(&self) -> &'static str {
"EXPR_BINARY_OPERATOR"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "EXPR_BINARY_OPERATOR" {
__attrs.push(("xsi:type", "EXPR_BINARY_OPERATOR".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.r#type.write_xml(w, "type", Some(""))?;
self.operator.write_xml(w, "operator", Some(""))?;
self.precedence_overridden
.write_xml(w, "precedence_overridden", Some(""))?;
self.left_operand
.write_xml(w, "left_operand", Some("EXPR_ITEM"))?;
self.right_operand
.write_xml(w, "right_operand", Some("EXPR_ITEM"))?;
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::ExprBinaryOperator {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __type = None;
let mut __operator = None;
let mut __precedence_overridden = None;
let mut __left_operand = None;
let mut __right_operand = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"type" => {
__type = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"operator" => {
__operator = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"precedence_overridden" => {
__precedence_overridden =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"left_operand" => {
__left_operand =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"right_operand" => {
__right_operand =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "EXPR_BINARY_OPERATOR".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::ExprBinaryOperator {
r#type: __type.ok_or_else(|| reader.missing_child("EXPR_BINARY_OPERATOR", "type"))?,
operator: __operator
.ok_or_else(|| reader.missing_child("EXPR_BINARY_OPERATOR", "operator"))?,
precedence_overridden: __precedence_overridden.unwrap_or(false),
left_operand: __left_operand
.ok_or_else(|| reader.missing_child("EXPR_BINARY_OPERATOR", "left_operand"))?,
right_operand: __right_operand
.ok_or_else(|| reader.missing_child("EXPR_BINARY_OPERATOR", "right_operand"))?,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::ExprItem {
fn xml_type_name(&self) -> &'static str {
match self {
crate::opt14::types::ExprItem::ExprBinaryOperator(x) => x.xml_type_name(),
crate::opt14::types::ExprItem::ExprLeaf(x) => x.xml_type_name(),
crate::opt14::types::ExprItem::ExprUnaryOperator(x) => x.xml_type_name(),
}
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
match self {
crate::opt14::types::ExprItem::ExprBinaryOperator(x) => x.write_xml(w, tag, declared),
crate::opt14::types::ExprItem::ExprLeaf(x) => x.write_xml(w, tag, declared),
crate::opt14::types::ExprItem::ExprUnaryOperator(x) => x.write_xml(w, tag, declared),
}
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::ExprItem {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
match start.xsi_type() {
Some("EXPR_BINARY_OPERATOR") => Ok(crate::opt14::types::ExprItem::ExprBinaryOperator(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("EXPR_LEAF") => Ok(crate::opt14::types::ExprItem::ExprLeaf(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("EXPR_UNARY_OPERATOR") => Ok(crate::opt14::types::ExprItem::ExprUnaryOperator(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
None => Err(crate::xml::runtime::XmlError::Parse(
"ExprItem: missing xsi:type".into(),
)),
Some(other) => Err(crate::xml::runtime::XmlError::Parse(format!(
"ExprItem: unknown xsi:type {other}: the ITS-XML OPT 1.4 schemas (Template.xsd, OpenehrProfile.xsd, Archetype.xsd) define no EXPR_ITEM subtype of that name"
))),
}
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::ExprLeaf {
fn xml_type_name(&self) -> &'static str {
"EXPR_LEAF"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "EXPR_LEAF" {
__attrs.push(("xsi:type", "EXPR_LEAF".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.r#type.write_xml(w, "type", Some(""))?;
self.item.write_xml(w, "item", Some(""))?;
self.reference_type
.write_xml(w, "reference_type", Some(""))?;
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::ExprLeaf {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __type = None;
let mut __item = None;
let mut __reference_type = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"type" => {
__type = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"item" => {
__item = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"reference_type" => {
__reference_type =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "EXPR_LEAF".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::ExprLeaf {
r#type: __type.ok_or_else(|| reader.missing_child("EXPR_LEAF", "type"))?,
item: __item.ok_or_else(|| reader.missing_child("EXPR_LEAF", "item"))?,
reference_type: __reference_type
.ok_or_else(|| reader.missing_child("EXPR_LEAF", "reference_type"))?,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::ExprOperator {
fn xml_type_name(&self) -> &'static str {
match self {
crate::opt14::types::ExprOperator::ExprBinaryOperator(x) => x.xml_type_name(),
crate::opt14::types::ExprOperator::ExprUnaryOperator(x) => x.xml_type_name(),
}
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
match self {
crate::opt14::types::ExprOperator::ExprBinaryOperator(x) => {
x.write_xml(w, tag, declared)
}
crate::opt14::types::ExprOperator::ExprUnaryOperator(x) => {
x.write_xml(w, tag, declared)
}
}
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::ExprOperator {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
match start.xsi_type() {
Some("EXPR_BINARY_OPERATOR") => {
Ok(crate::opt14::types::ExprOperator::ExprBinaryOperator(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
))
}
Some("EXPR_UNARY_OPERATOR") => {
Ok(crate::opt14::types::ExprOperator::ExprUnaryOperator(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
))
}
None => Err(crate::xml::runtime::XmlError::Parse(
"ExprOperator: missing xsi:type".into(),
)),
Some(other) => Err(crate::xml::runtime::XmlError::Parse(format!(
"ExprOperator: unknown xsi:type {other}: the ITS-XML OPT 1.4 schemas (Template.xsd, OpenehrProfile.xsd, Archetype.xsd) define no EXPR_OPERATOR subtype of that name"
))),
}
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::ExprUnaryOperator {
fn xml_type_name(&self) -> &'static str {
"EXPR_UNARY_OPERATOR"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "EXPR_UNARY_OPERATOR" {
__attrs.push(("xsi:type", "EXPR_UNARY_OPERATOR".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.r#type.write_xml(w, "type", Some(""))?;
self.operator.write_xml(w, "operator", Some(""))?;
self.precedence_overridden
.write_xml(w, "precedence_overridden", Some(""))?;
self.operand.write_xml(w, "operand", Some("EXPR_ITEM"))?;
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::ExprUnaryOperator {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __type = None;
let mut __operator = None;
let mut __precedence_overridden = None;
let mut __operand = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"type" => {
__type = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"operator" => {
__operator = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"precedence_overridden" => {
__precedence_overridden =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"operand" => {
__operand = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "EXPR_UNARY_OPERATOR".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::ExprUnaryOperator {
r#type: __type.ok_or_else(|| reader.missing_child("EXPR_UNARY_OPERATOR", "type"))?,
operator: __operator
.ok_or_else(|| reader.missing_child("EXPR_UNARY_OPERATOR", "operator"))?,
precedence_overridden: __precedence_overridden.unwrap_or(false),
operand: __operand
.ok_or_else(|| reader.missing_child("EXPR_UNARY_OPERATOR", "operand"))?,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::FlatArchetypeOntology {
fn xml_type_name(&self) -> &'static str {
"FLAT_ARCHETYPE_ONTOLOGY"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "FLAT_ARCHETYPE_ONTOLOGY" {
__attrs.push(("xsi:type", "FLAT_ARCHETYPE_ONTOLOGY".to_string()));
}
}
__attrs.push(("archetype_id", self.archetype_id.to_string()));
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
for v in &self.term_definitions {
v.write_xml(w, "term_definitions", Some("CodeDefinitionSet"))?;
}
for v in &self.constraint_definitions {
v.write_xml(w, "constraint_definitions", Some("CodeDefinitionSet"))?;
}
for v in &self.term_bindings {
v.write_xml(w, "term_bindings", Some("TermBindingSet"))?;
}
for v in &self.constraint_bindings {
v.write_xml(w, "constraint_bindings", Some("ConstraintBindingSet"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::FlatArchetypeOntology {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __term_definitions = Vec::new();
let mut __constraint_definitions = Vec::new();
let mut __term_bindings = Vec::new();
let mut __constraint_bindings = Vec::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"term_definitions" => {
__term_definitions
.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"constraint_definitions" => {
__constraint_definitions
.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"term_bindings" => {
__term_bindings.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"constraint_bindings" => {
__constraint_bindings
.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "FLAT_ARCHETYPE_ONTOLOGY".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::FlatArchetypeOntology {
archetype_id: start
.attr("archetype_id")
.ok_or_else(|| reader.missing_attribute("FLAT_ARCHETYPE_ONTOLOGY", "archetype_id"))?
.to_string(),
term_definitions: __term_definitions,
constraint_definitions: __constraint_definitions,
term_bindings: __term_bindings,
constraint_bindings: __constraint_bindings,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::Intervalofdate {
fn xml_type_name(&self) -> &'static str {
"IntervalOfDate"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "IntervalOfDate" {
__attrs.push(("xsi:type", "IntervalOfDate".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
if let Some(v) = &self.lower_included {
v.write_xml(w, "lower_included", Some(""))?;
}
if let Some(v) = &self.upper_included {
v.write_xml(w, "upper_included", Some(""))?;
}
self.lower_unbounded
.write_xml(w, "lower_unbounded", Some(""))?;
self.upper_unbounded
.write_xml(w, "upper_unbounded", Some(""))?;
if let Some(v) = &self.lower {
v.write_xml(w, "lower", Some(""))?;
}
if let Some(v) = &self.upper {
v.write_xml(w, "upper", Some(""))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::Intervalofdate {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __lower_included = None;
let mut __upper_included = None;
let mut __lower_unbounded = None;
let mut __upper_unbounded = None;
let mut __lower = None;
let mut __upper = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"lower_included" => {
__lower_included =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"upper_included" => {
__upper_included =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"lower_unbounded" => {
__lower_unbounded =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"upper_unbounded" => {
__upper_unbounded =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"lower" => {
__lower = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"upper" => {
__upper = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "IntervalOfDate".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::Intervalofdate {
lower_included: __lower_included,
upper_included: __upper_included,
lower_unbounded: __lower_unbounded.unwrap_or(false),
upper_unbounded: __upper_unbounded.unwrap_or(false),
lower: __lower,
upper: __upper,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::Intervalofdatetime {
fn xml_type_name(&self) -> &'static str {
"IntervalOfDateTime"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "IntervalOfDateTime" {
__attrs.push(("xsi:type", "IntervalOfDateTime".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
if let Some(v) = &self.lower_included {
v.write_xml(w, "lower_included", Some(""))?;
}
if let Some(v) = &self.upper_included {
v.write_xml(w, "upper_included", Some(""))?;
}
self.lower_unbounded
.write_xml(w, "lower_unbounded", Some(""))?;
self.upper_unbounded
.write_xml(w, "upper_unbounded", Some(""))?;
if let Some(v) = &self.lower {
v.write_xml(w, "lower", Some(""))?;
}
if let Some(v) = &self.upper {
v.write_xml(w, "upper", Some(""))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::Intervalofdatetime {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __lower_included = None;
let mut __upper_included = None;
let mut __lower_unbounded = None;
let mut __upper_unbounded = None;
let mut __lower = None;
let mut __upper = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"lower_included" => {
__lower_included =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"upper_included" => {
__upper_included =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"lower_unbounded" => {
__lower_unbounded =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"upper_unbounded" => {
__upper_unbounded =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"lower" => {
__lower = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"upper" => {
__upper = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "IntervalOfDateTime".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::Intervalofdatetime {
lower_included: __lower_included,
upper_included: __upper_included,
lower_unbounded: __lower_unbounded.unwrap_or(false),
upper_unbounded: __upper_unbounded.unwrap_or(false),
lower: __lower,
upper: __upper,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::Intervalofduration {
fn xml_type_name(&self) -> &'static str {
"IntervalOfDuration"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "IntervalOfDuration" {
__attrs.push(("xsi:type", "IntervalOfDuration".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
if let Some(v) = &self.lower_included {
v.write_xml(w, "lower_included", Some(""))?;
}
if let Some(v) = &self.upper_included {
v.write_xml(w, "upper_included", Some(""))?;
}
self.lower_unbounded
.write_xml(w, "lower_unbounded", Some(""))?;
self.upper_unbounded
.write_xml(w, "upper_unbounded", Some(""))?;
if let Some(v) = &self.lower {
v.write_xml(w, "lower", Some(""))?;
}
if let Some(v) = &self.upper {
v.write_xml(w, "upper", Some(""))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::Intervalofduration {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __lower_included = None;
let mut __upper_included = None;
let mut __lower_unbounded = None;
let mut __upper_unbounded = None;
let mut __lower = None;
let mut __upper = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"lower_included" => {
__lower_included =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"upper_included" => {
__upper_included =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"lower_unbounded" => {
__lower_unbounded =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"upper_unbounded" => {
__upper_unbounded =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"lower" => {
__lower = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"upper" => {
__upper = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "IntervalOfDuration".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::Intervalofduration {
lower_included: __lower_included,
upper_included: __upper_included,
lower_unbounded: __lower_unbounded.unwrap_or(false),
upper_unbounded: __upper_unbounded.unwrap_or(false),
lower: __lower,
upper: __upper,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::Intervalofinteger {
fn xml_type_name(&self) -> &'static str {
"IntervalOfInteger"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "IntervalOfInteger" {
__attrs.push(("xsi:type", "IntervalOfInteger".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
if let Some(v) = &self.lower_included {
v.write_xml(w, "lower_included", Some(""))?;
}
if let Some(v) = &self.upper_included {
v.write_xml(w, "upper_included", Some(""))?;
}
self.lower_unbounded
.write_xml(w, "lower_unbounded", Some(""))?;
self.upper_unbounded
.write_xml(w, "upper_unbounded", Some(""))?;
if let Some(v) = &self.lower {
v.write_xml(w, "lower", Some(""))?;
}
if let Some(v) = &self.upper {
v.write_xml(w, "upper", Some(""))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::Intervalofinteger {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __lower_included = None;
let mut __upper_included = None;
let mut __lower_unbounded = None;
let mut __upper_unbounded = None;
let mut __lower = None;
let mut __upper = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"lower_included" => {
__lower_included =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"upper_included" => {
__upper_included =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"lower_unbounded" => {
__lower_unbounded =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"upper_unbounded" => {
__upper_unbounded =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"lower" => {
__lower = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"upper" => {
__upper = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "IntervalOfInteger".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::Intervalofinteger {
lower_included: __lower_included,
upper_included: __upper_included,
lower_unbounded: __lower_unbounded.unwrap_or(false),
upper_unbounded: __upper_unbounded.unwrap_or(false),
lower: __lower,
upper: __upper,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::Intervalofreal {
fn xml_type_name(&self) -> &'static str {
"IntervalOfReal"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "IntervalOfReal" {
__attrs.push(("xsi:type", "IntervalOfReal".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
if let Some(v) = &self.lower_included {
v.write_xml(w, "lower_included", Some(""))?;
}
if let Some(v) = &self.upper_included {
v.write_xml(w, "upper_included", Some(""))?;
}
self.lower_unbounded
.write_xml(w, "lower_unbounded", Some(""))?;
self.upper_unbounded
.write_xml(w, "upper_unbounded", Some(""))?;
if let Some(v) = &self.lower {
v.write_xml(w, "lower", Some(""))?;
}
if let Some(v) = &self.upper {
v.write_xml(w, "upper", Some(""))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::Intervalofreal {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __lower_included = None;
let mut __upper_included = None;
let mut __lower_unbounded = None;
let mut __upper_unbounded = None;
let mut __lower = None;
let mut __upper = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"lower_included" => {
__lower_included =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"upper_included" => {
__upper_included =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"lower_unbounded" => {
__lower_unbounded =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"upper_unbounded" => {
__upper_unbounded =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"lower" => {
__lower = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"upper" => {
__upper = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "IntervalOfReal".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::Intervalofreal {
lower_included: __lower_included,
upper_included: __upper_included,
lower_unbounded: __lower_unbounded.unwrap_or(false),
upper_unbounded: __upper_unbounded.unwrap_or(false),
lower: __lower,
upper: __upper,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::Intervaloftime {
fn xml_type_name(&self) -> &'static str {
"IntervalOfTime"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "IntervalOfTime" {
__attrs.push(("xsi:type", "IntervalOfTime".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
if let Some(v) = &self.lower_included {
v.write_xml(w, "lower_included", Some(""))?;
}
if let Some(v) = &self.upper_included {
v.write_xml(w, "upper_included", Some(""))?;
}
self.lower_unbounded
.write_xml(w, "lower_unbounded", Some(""))?;
self.upper_unbounded
.write_xml(w, "upper_unbounded", Some(""))?;
if let Some(v) = &self.lower {
v.write_xml(w, "lower", Some(""))?;
}
if let Some(v) = &self.upper {
v.write_xml(w, "upper", Some(""))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::Intervaloftime {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __lower_included = None;
let mut __upper_included = None;
let mut __lower_unbounded = None;
let mut __upper_unbounded = None;
let mut __lower = None;
let mut __upper = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"lower_included" => {
__lower_included =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"upper_included" => {
__upper_included =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"lower_unbounded" => {
__lower_unbounded =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"upper_unbounded" => {
__upper_unbounded =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"lower" => {
__lower = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"upper" => {
__upper = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "IntervalOfTime".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::Intervaloftime {
lower_included: __lower_included,
upper_included: __upper_included,
lower_unbounded: __lower_unbounded.unwrap_or(false),
upper_unbounded: __upper_unbounded.unwrap_or(false),
lower: __lower,
upper: __upper,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::NonTerminalState {
fn xml_type_name(&self) -> &'static str {
"NON_TERMINAL_STATE"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "NON_TERMINAL_STATE" {
__attrs.push(("xsi:type", "NON_TERMINAL_STATE".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.name.write_xml(w, "name", Some(""))?;
for v in &self.transitions {
v.write_xml(w, "transitions", Some("TRANSITION"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::NonTerminalState {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __name = None;
let mut __transitions = Vec::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"name" => {
__name = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"transitions" => {
__transitions.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "NON_TERMINAL_STATE".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::NonTerminalState {
name: __name.ok_or_else(|| reader.missing_child("NON_TERMINAL_STATE", "name"))?,
transitions: __transitions,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::OperationalTemplate {
fn xml_type_name(&self) -> &'static str {
"OPERATIONAL_TEMPLATE"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "OPERATIONAL_TEMPLATE" {
__attrs.push(("xsi:type", "OPERATIONAL_TEMPLATE".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.language
.write_xml(w, "language", Some("CODE_PHRASE"))?;
if let Some(v) = &self.is_controlled {
v.write_xml(w, "is_controlled", Some(""))?;
}
if let Some(v) = &self.description {
v.write_xml(w, "description", Some("RESOURCE_DESCRIPTION"))?;
}
if let Some(v) = &self.revision_history {
v.write_xml(w, "revision_history", Some("REVISION_HISTORY"))?;
}
if let Some(v) = &self.uid {
v.write_xml(w, "uid", Some("HIER_OBJECT_ID"))?;
}
self.template_id
.write_xml(w, "template_id", Some("TEMPLATE_ID"))?;
self.concept.write_xml(w, "concept", Some(""))?;
self.definition
.write_xml(w, "definition", Some("C_ARCHETYPE_ROOT"))?;
if let Some(v) = &self.ontology {
v.write_xml(w, "ontology", Some("FLAT_ARCHETYPE_ONTOLOGY"))?;
}
for v in &self.component_ontologies {
v.write_xml(w, "component_ontologies", Some("FLAT_ARCHETYPE_ONTOLOGY"))?;
}
for v in &self.annotations {
v.write_xml(w, "annotations", Some("ANNOTATION"))?;
}
if let Some(v) = &self.constraints {
v.write_xml(w, "constraints", Some("T_CONSTRAINT"))?;
}
if let Some(v) = &self.view {
v.write_xml(w, "view", Some(""))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::OperationalTemplate {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __language = None;
let mut __is_controlled = None;
let mut __description = None;
let mut __revision_history = None;
let mut __uid = None;
let mut __template_id = None;
let mut __concept = None;
let mut __definition = None;
let mut __ontology = None;
let mut __component_ontologies = Vec::new();
let mut __annotations = Vec::new();
let mut __constraints = None;
let mut __view = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"language" => {
__language = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"is_controlled" => {
__is_controlled =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"description" => {
__description = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"revision_history" => {
__revision_history =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"uid" => {
__uid = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"template_id" => {
__template_id = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"concept" => {
__concept = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"definition" => {
__definition = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"ontology" => {
__ontology = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"component_ontologies" => {
__component_ontologies
.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"annotations" => {
__annotations.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"constraints" => {
__constraints = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"view" => {
__view = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "OPERATIONAL_TEMPLATE".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::OperationalTemplate {
language: __language
.ok_or_else(|| reader.missing_child("OPERATIONAL_TEMPLATE", "language"))?,
is_controlled: __is_controlled,
description: __description,
revision_history: __revision_history,
uid: __uid,
template_id: __template_id
.ok_or_else(|| reader.missing_child("OPERATIONAL_TEMPLATE", "template_id"))?,
concept: __concept
.ok_or_else(|| reader.missing_child("OPERATIONAL_TEMPLATE", "concept"))?,
definition: __definition
.ok_or_else(|| reader.missing_child("OPERATIONAL_TEMPLATE", "definition"))?,
ontology: __ontology,
component_ontologies: __component_ontologies,
annotations: __annotations,
constraints: __constraints,
view: __view,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::ResourceDescription {
fn xml_type_name(&self) -> &'static str {
"RESOURCE_DESCRIPTION"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "RESOURCE_DESCRIPTION" {
__attrs.push(("xsi:type", "RESOURCE_DESCRIPTION".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
for (k, v) in &self.original_author {
w.write_kv_element("original_author", k, v)?;
}
for v in &self.other_contributors {
v.write_xml(w, "other_contributors", Some(""))?;
}
self.lifecycle_state
.write_xml(w, "lifecycle_state", Some(""))?;
if let Some(v) = &self.resource_package_uri {
v.write_xml(w, "resource_package_uri", Some(""))?;
}
if let Some(m) = &self.other_details {
for (k, v) in m {
w.write_kv_element("other_details", k, v)?;
}
}
for v in &self.details {
v.write_xml(w, "details", Some("RESOURCE_DESCRIPTION_ITEM"))?;
}
if let Some(v) = &self.parent_resource {
v.write_xml(w, "parent_resource", Some("AUTHORED_RESOURCE"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::ResourceDescription {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __original_author = indexmap::IndexMap::new();
let mut __other_contributors = Vec::new();
let mut __lifecycle_state = None;
let mut __resource_package_uri = None;
let mut __other_details = indexmap::IndexMap::new();
let mut __details = Vec::new();
let mut __parent_resource = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"original_author" => {
let __k = __c
.attr("id")
.ok_or_else(|| reader.missing_attribute("StringDictionaryItem", "id"))?
.to_string();
let __v: String = crate::xml::runtime::FromXml::from_xml(reader, &__c)?;
__original_author.insert(__k, __v);
}
"other_contributors" => {
__other_contributors
.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"lifecycle_state" => {
__lifecycle_state =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"resource_package_uri" => {
__resource_package_uri =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"other_details" => {
let __k = __c
.attr("id")
.ok_or_else(|| reader.missing_attribute("StringDictionaryItem", "id"))?
.to_string();
let __v: String = crate::xml::runtime::FromXml::from_xml(reader, &__c)?;
__other_details.insert(__k, __v);
}
"details" => {
__details.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"parent_resource" => {
__parent_resource =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "RESOURCE_DESCRIPTION".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::ResourceDescription {
original_author: __original_author,
other_contributors: __other_contributors,
lifecycle_state: __lifecycle_state
.ok_or_else(|| reader.missing_child("RESOURCE_DESCRIPTION", "lifecycle_state"))?,
resource_package_uri: __resource_package_uri,
other_details: if __other_details.is_empty() {
None
} else {
Some(__other_details)
},
details: __details,
parent_resource: __parent_resource,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::ResourceDescriptionItem {
fn xml_type_name(&self) -> &'static str {
"RESOURCE_DESCRIPTION_ITEM"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "RESOURCE_DESCRIPTION_ITEM" {
__attrs.push(("xsi:type", "RESOURCE_DESCRIPTION_ITEM".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.language
.write_xml(w, "language", Some("CODE_PHRASE"))?;
self.purpose.write_xml(w, "purpose", Some(""))?;
for v in &self.keywords {
v.write_xml(w, "keywords", Some(""))?;
}
if let Some(v) = &self.use_ {
v.write_xml(w, "use", Some(""))?;
}
if let Some(v) = &self.misuse {
v.write_xml(w, "misuse", Some(""))?;
}
if let Some(v) = &self.copyright {
v.write_xml(w, "copyright", Some(""))?;
}
if let Some(m) = &self.original_resource_uri {
for (k, v) in m {
w.write_kv_element("original_resource_uri", k, v)?;
}
}
if let Some(m) = &self.other_details {
for (k, v) in m {
w.write_kv_element("other_details", k, v)?;
}
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::ResourceDescriptionItem {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __language = None;
let mut __purpose = None;
let mut __keywords = Vec::new();
let mut __use_ = None;
let mut __misuse = None;
let mut __copyright = None;
let mut __original_resource_uri = indexmap::IndexMap::new();
let mut __other_details = indexmap::IndexMap::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"language" => {
__language = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"purpose" => {
__purpose = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"keywords" => {
__keywords.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"use" => {
__use_ = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"misuse" => {
__misuse = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"copyright" => {
__copyright = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"original_resource_uri" => {
let __k = __c
.attr("id")
.ok_or_else(|| reader.missing_attribute("StringDictionaryItem", "id"))?
.to_string();
let __v: String = crate::xml::runtime::FromXml::from_xml(reader, &__c)?;
__original_resource_uri.insert(__k, __v);
}
"other_details" => {
let __k = __c
.attr("id")
.ok_or_else(|| reader.missing_attribute("StringDictionaryItem", "id"))?
.to_string();
let __v: String = crate::xml::runtime::FromXml::from_xml(reader, &__c)?;
__other_details.insert(__k, __v);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "RESOURCE_DESCRIPTION_ITEM".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::ResourceDescriptionItem {
language: __language
.ok_or_else(|| reader.missing_child("RESOURCE_DESCRIPTION_ITEM", "language"))?,
purpose: __purpose.unwrap_or(String::new()),
keywords: __keywords,
use_: __use_,
misuse: __misuse,
copyright: __copyright,
original_resource_uri: if __original_resource_uri.is_empty() {
None
} else {
Some(__original_resource_uri)
},
other_details: if __other_details.is_empty() {
None
} else {
Some(__other_details)
},
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::State {
fn xml_type_name(&self) -> &'static str {
match self {
crate::opt14::types::State::NonTerminalState(x) => x.xml_type_name(),
crate::opt14::types::State::TerminalState(x) => x.xml_type_name(),
}
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
match self {
crate::opt14::types::State::NonTerminalState(x) => x.write_xml(w, tag, declared),
crate::opt14::types::State::TerminalState(x) => x.write_xml(w, tag, declared),
}
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::State {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
match start.xsi_type() {
Some("NON_TERMINAL_STATE") => Ok(crate::opt14::types::State::NonTerminalState(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
Some("TERMINAL_STATE") => Ok(crate::opt14::types::State::TerminalState(
crate::xml::runtime::FromXml::from_xml(reader, start)?,
)),
None => Err(crate::xml::runtime::XmlError::Parse(
"State: missing xsi:type".into(),
)),
Some(other) => Err(crate::xml::runtime::XmlError::Parse(format!(
"State: unknown xsi:type {other}: the ITS-XML OPT 1.4 schemas (Template.xsd, OpenehrProfile.xsd, Archetype.xsd) define no STATE subtype of that name"
))),
}
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::StateMachine {
fn xml_type_name(&self) -> &'static str {
"STATE_MACHINE"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "STATE_MACHINE" {
__attrs.push(("xsi:type", "STATE_MACHINE".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
for v in &self.states {
v.write_xml(w, "states", Some("STATE"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::StateMachine {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __states = Vec::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"states" => {
__states.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "STATE_MACHINE".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::StateMachine { states: __states })
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::TerminalState {
fn xml_type_name(&self) -> &'static str {
"TERMINAL_STATE"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "TERMINAL_STATE" {
__attrs.push(("xsi:type", "TERMINAL_STATE".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.name.write_xml(w, "name", Some(""))?;
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::TerminalState {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __name = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"name" => {
__name = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "TERMINAL_STATE".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::TerminalState {
name: __name.ok_or_else(|| reader.missing_child("TERMINAL_STATE", "name"))?,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::TermBindingItem {
fn xml_type_name(&self) -> &'static str {
"TERM_BINDING_ITEM"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "TERM_BINDING_ITEM" {
__attrs.push(("xsi:type", "TERM_BINDING_ITEM".to_string()));
}
}
__attrs.push(("code", self.code.to_string()));
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.value.write_xml(w, "value", Some("CODE_PHRASE"))?;
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::TermBindingItem {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __value = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"value" => {
__value = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "TERM_BINDING_ITEM".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::TermBindingItem {
code: start
.attr("code")
.ok_or_else(|| reader.missing_attribute("TERM_BINDING_ITEM", "code"))?
.to_string(),
value: __value.ok_or_else(|| reader.missing_child("TERM_BINDING_ITEM", "value"))?,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::Transition {
fn xml_type_name(&self) -> &'static str {
"TRANSITION"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "TRANSITION" {
__attrs.push(("xsi:type", "TRANSITION".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.event.write_xml(w, "event", Some(""))?;
if let Some(v) = &self.action {
v.write_xml(w, "action", Some(""))?;
}
if let Some(v) = &self.guard {
v.write_xml(w, "guard", Some(""))?;
}
if let Some(v) = &self.next_state {
v.write_xml(w, "next_state", Some("STATE"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::Transition {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __event = None;
let mut __action = None;
let mut __guard = None;
let mut __next_state = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"event" => {
__event = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"action" => {
__action = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"guard" => {
__guard = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"next_state" => {
__next_state = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "TRANSITION".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::Transition {
event: __event.ok_or_else(|| reader.missing_child("TRANSITION", "event"))?,
action: __action,
guard: __guard,
next_state: __next_state,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::TranslationDetails {
fn xml_type_name(&self) -> &'static str {
"TRANSLATION_DETAILS"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "TRANSLATION_DETAILS" {
__attrs.push(("xsi:type", "TRANSLATION_DETAILS".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.language
.write_xml(w, "language", Some("CODE_PHRASE"))?;
for (k, v) in &self.author {
w.write_kv_element("author", k, v)?;
}
if let Some(v) = &self.accreditation {
v.write_xml(w, "accreditation", Some(""))?;
}
if let Some(m) = &self.other_details {
for (k, v) in m {
w.write_kv_element("other_details", k, v)?;
}
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::TranslationDetails {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __language = None;
let mut __author = indexmap::IndexMap::new();
let mut __accreditation = None;
let mut __other_details = indexmap::IndexMap::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"language" => {
__language = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"author" => {
let __k = __c
.attr("id")
.ok_or_else(|| reader.missing_attribute("StringDictionaryItem", "id"))?
.to_string();
let __v: String = crate::xml::runtime::FromXml::from_xml(reader, &__c)?;
__author.insert(__k, __v);
}
"accreditation" => {
__accreditation =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"other_details" => {
let __k = __c
.attr("id")
.ok_or_else(|| reader.missing_attribute("StringDictionaryItem", "id"))?
.to_string();
let __v: String = crate::xml::runtime::FromXml::from_xml(reader, &__c)?;
__other_details.insert(__k, __v);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "TRANSLATION_DETAILS".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::TranslationDetails {
language: __language
.ok_or_else(|| reader.missing_child("TRANSLATION_DETAILS", "language"))?,
author: __author,
accreditation: __accreditation,
other_details: if __other_details.is_empty() {
None
} else {
Some(__other_details)
},
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::TAttribute {
fn xml_type_name(&self) -> &'static str {
"T_ATTRIBUTE"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "T_ATTRIBUTE" {
__attrs.push(("xsi:type", "T_ATTRIBUTE".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.rm_attribute_name
.write_xml(w, "rm_attribute_name", Some(""))?;
for v in &self.children {
v.write_xml(w, "children", Some("T_COMPLEX_OBJECT"))?;
}
self.differential_path
.write_xml(w, "differential_path", Some(""))?;
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::TAttribute {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __rm_attribute_name = None;
let mut __children = Vec::new();
let mut __differential_path = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"rm_attribute_name" => {
__rm_attribute_name =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"children" => {
__children.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"differential_path" => {
__differential_path =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "T_ATTRIBUTE".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::TAttribute {
rm_attribute_name: __rm_attribute_name
.ok_or_else(|| reader.missing_child("T_ATTRIBUTE", "rm_attribute_name"))?,
children: __children,
differential_path: __differential_path
.ok_or_else(|| reader.missing_child("T_ATTRIBUTE", "differential_path"))?,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::TComplexObject {
fn xml_type_name(&self) -> &'static str {
"T_COMPLEX_OBJECT"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "T_COMPLEX_OBJECT" {
__attrs.push(("xsi:type", "T_COMPLEX_OBJECT".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
self.rm_type_name.write_xml(w, "rm_type_name", Some(""))?;
self.occurrences
.write_xml(w, "occurrences", Some("IntervalOfInteger"))?;
self.node_id.write_xml(w, "node_id", Some(""))?;
for v in &self.attributes {
v.write_xml(w, "attributes", Some("C_ATTRIBUTE"))?;
}
if let Some(v) = &self.default_value {
v.write_xml(w, "default_value", Some("DATA_VALUE"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::TComplexObject {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __rm_type_name = None;
let mut __occurrences = None;
let mut __node_id = None;
let mut __attributes = Vec::new();
let mut __default_value = None;
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"rm_type_name" => {
__rm_type_name =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"occurrences" => {
__occurrences = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"node_id" => {
__node_id = Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"attributes" => {
__attributes.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
"default_value" => {
__default_value =
Some(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "T_COMPLEX_OBJECT".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::TComplexObject {
rm_type_name: __rm_type_name.unwrap_or(String::new()),
occurrences: __occurrences.unwrap_or(crate::opt14::types::Intervalofinteger {
lower_included: Some(true),
upper_included: Some(true),
lower_unbounded: false,
upper_unbounded: false,
lower: Some(0),
upper: Some(1),
}),
node_id: __node_id.unwrap_or(String::new()),
attributes: __attributes,
default_value: __default_value,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::TConstraint {
fn xml_type_name(&self) -> &'static str {
"T_CONSTRAINT"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "T_CONSTRAINT" {
__attrs.push(("xsi:type", "T_CONSTRAINT".to_string()));
}
}
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
for v in &self.attributes {
v.write_xml(w, "attributes", Some("T_ATTRIBUTE"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::TConstraint {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __attributes = Vec::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"attributes" => {
__attributes.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "T_CONSTRAINT".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::TConstraint {
attributes: __attributes,
})
}
}
impl crate::xml::runtime::ToXml for crate::opt14::types::Termbindingset {
fn xml_type_name(&self) -> &'static str {
"TermBindingSet"
}
fn write_xml(
&self,
w: &mut crate::xml::runtime::XmlWriter,
tag: &str,
declared: Option<&str>,
) -> Result<(), crate::xml::runtime::XmlError> {
let mut __attrs: Vec<(&str, String)> = Vec::new();
if let Some(d) = declared {
if d != "TermBindingSet" {
__attrs.push(("xsi:type", "TermBindingSet".to_string()));
}
}
__attrs.push(("terminology", self.terminology.to_string()));
let mut __e = quick_xml::events::BytesStart::new(tag);
for (k, v) in &__attrs {
__e.push_attribute((*k, v.as_str()));
}
w.write_start(__e)?;
for v in &self.items {
v.write_xml(w, "items", Some("TERM_BINDING_ITEM"))?;
}
w.write_end(tag)?;
Ok(())
}
}
impl crate::xml::runtime::FromXml for crate::opt14::types::Termbindingset {
fn from_xml(
reader: &mut crate::xml::runtime::XmlReader,
start: &crate::xml::runtime::StartTag,
) -> Result<Self, crate::xml::runtime::XmlError> {
let mut __items = Vec::new();
loop {
match reader.read()? {
crate::xml::runtime::XmlEvent::Start(__c) => match __c.name.as_str() {
"items" => {
__items.push(crate::xml::runtime::FromXml::from_xml(reader, &__c)?);
}
_ => {
return Err(crate::xml::runtime::XmlError::UndeclaredChild {
owner: "TermBindingSet".to_owned(),
child: __c.name.clone(),
});
}
},
crate::xml::runtime::XmlEvent::End => break,
crate::xml::runtime::XmlEvent::Text(_) => {}
crate::xml::runtime::XmlEvent::Eof => {
return Err(crate::xml::runtime::XmlError::Parse(
"unexpected EOF".into(),
));
}
}
}
Ok(crate::opt14::types::Termbindingset {
terminology: start
.attr("terminology")
.ok_or_else(|| reader.missing_attribute("TermBindingSet", "terminology"))?
.to_string(),
items: __items,
})
}
}