diff --git a/Gemfile b/Gemfile index d47c6f5..b68ee49 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,22 @@ source "https://rubygems.org" +gem "lutaml", + github: "lutaml/lutaml", + branch: "update/xsd_support_metanorma_plugin" +gem "lutaml-model", + github: "lutaml/lutaml-model", + branch: "main" +gem "lutaml-xsd", + github: "lutaml/lutaml-xsd", + branch: "update/liquid_drop_methods" +gem "metanorma" gem "metanorma-cli" -# gem "metanorma-nist", source: "https://rubygems.pkg.github.com/metanorma" +gem "metanorma-plugin-lutaml", + github: "metanorma/metanorma-plugin-lutaml", + branch: "feature/unitsml_liquid_filters" +gem "metanorma-standoc", + github: "metanorma/metanorma-standoc", + branch: "update/lutaml_xsd_preprocessor_support" +gem "metanorma-utils", + github: "metanorma/metanorma-utils", + branch: "main" diff --git a/sources/unitsml-xml-schema/document.adoc b/sources/unitsml-xml-schema/document.adoc new file mode 100644 index 0000000..133f1ca --- /dev/null +++ b/sources/unitsml-xml-schema/document.adoc @@ -0,0 +1,45 @@ += CalConnect Standard: UnitsML XML schema specification +:title: UnitsML XML schema specification +:docnumber: 36811 +:copyright-year: 2025 +:doctype: standard +:edition: 1 +:status: committee-draft +:revdate: 2025-08-22 +:published-date: 2025-08-22 +:technical-committee: TC UNITS +:fullname: Ronald Tse +:surname: Tse +:givenname: Ronald +:affiliation: Ribose Inc. +:fullname_2: Suleman Uzair +:surname_2: Uzair +:givenname_2: Suleman +:affiliation_2: Ribose Inc. +:imagesdir: images +:mn-document-class: cc +:mn-output-extensions: xml,html,pdf,rxl +:local-cache-only: +:data-uri-image: + +include::sections/00-foreword.adoc[] + +include::sections/00-intro.adoc[] + +include::sections/01-scope.adoc[] + +include::sections/02-normrefs.adoc[] + +include::sections/03-terms.adoc[] + +include::sections/04-conventions.adoc[] + +include::sections/05-schema.adoc[] + +include::sections/06-elements.adoc[] + +include::sections/07-complex-types.adoc[] + +include::sections/08-attribute-groups.adoc[] + +include::sections/99-bibliography.adoc[] diff --git a/sources/unitsml-xml-schema/schemas/unitsml-v1.0-csd04.xsd b/sources/unitsml-xml-schema/schemas/unitsml-v1.0-csd04.xsd new file mode 100644 index 0000000..23e821f --- /dev/null +++ b/sources/unitsml-xml-schema/schemas/unitsml-v1.0-csd04.xsd @@ -0,0 +1,1368 @@ + + + + + + + + Container for UnitsML units, quantities, and prefixes. + + + + + ComplexType for the root element of an UnitsML document. + + + + + + + + + + + + + + Container for units. Use in UnitsML container or directly incorporate into a host schema. + + + + + Element for describing units. Use in containers UnitSet or directly incorporate into a host schema. + + + + + Container for describing the system of units. + + + + + Element containing the unit name. + + + + + Element containing various unit symbols. Examples include Aring (ASCII), Å (HTML). + + + + + Element for descriptive information, including version changes to the unit. + + + + + Element for listing the unit code value from a specific code list. + + + + + Container for defining derived units in terms of their root units. This allows a precise definition of a wide range of units. The goal is to improve interoperability among applications and databases which use derived units based on commonly encountered root units. + + + + + Element for a root unit (from an extensive enumerated list) allowing an optional prefix and power. E.g., mm^2 + + + + + Element for those special cases where the root unit needed is not included in the enumerated list in the above element. + + + + + Container for providing conversion information to other units. + + + + + Element for providing factors for a conversion equation from another unit; stem:[y = d + ((b / c) (x + a))] + + + + + Element for descriptive information. + + + + + Element for providing unit conversion information for conversions that are more complex than the Float64ConversionFrom linear equation. + + + + + Element for providing conversion based on SOAP/WSDL calls to a remote server. + + + + + Element to describe the WSDL service. + + + + + Element for a description of the SpecialConversionFrom. + + + + + Element for all quantities that can be expressed using this unit. + + + + + Element to describe the definition of the unit. + + + + + Element to describe the historical development of the unit. + + + + + Element as a placeholder for additional information. + + + + + + Container for items that are counted and are (in practice) combined with scientific units of measure. + + + + + Container for a single counted item. + + + + + Element containing the item name(s). + + + + + Element containing symbols for the item. + + + + + Element for descriptive information, including version changes to the item. + + + + + Element to describe the definition of the item. + + + + + Element to describe the historical development of the item. + + + + + Element as a placeholder for additional information. + + + + + + Container for quantities. + + + + + Element for describing quantities and referencing corresponding units. Use in container or directly incorporate into a host schema. + + + + + Element containing the quantity name. + + + + + Element containing various quantity symbols. + + + + + Element for referencing a unit of measure from within the Quantity element. + + + + + Element for descriptive information, including version changes to the unit. + + + + + Element to describe the definition of the quantity. + + + + + Element to describe the historical development of the quantity. + + + + + Element as a placeholder for additional information. + + + + + + Container for dimensions. + + + + + Element to express the dimension of a unit or quantity in terms of the SI base quantities length, mass, time, electric current, thermodynamic temperature, amount of substance, and luminous intensity. + + + + + Element containing the dimension of the quantity length. + + + + + Element containing the dimension of the quantity mass. + + + + + Element containing the dimension of the quantity time. + + + + + Element containing the dimension of the quantity electric current. + + + + + Element containing the dimension of the quantity thermodynamic temerature. + + + + + Element containing the dimension of the quantity amount of substance. + + + + + Element containing the dimension of the quantity luminous intensity. + + + + + Element containing the dimension of the quantity plane angle. + + + + + Element containing the dimension of any item. Note: this element is meant to be used to allow counted items to be included in the dimensioning of a derived quantity, e.g., electrons per time; usage of this element does not conform to the SI description of the dimension of a quantity in terms of seven base quantities. + + + + + + Container for prefixes. + + + + + Element containing information about a prefix. + + + + + Element containing the prefix name. + + + + + Element containing prefix symbols. + + + + + + URI indicating the unitID of the starting unit for the conversion. For units which are defined in the same document, the URI should consist of a pound sign (#) followed by the ID value. + + + + URI indicating the unitID of the starting unit for the conversion. For units which are defined in the same document, the URI should consist of a pound sign (#) followed by the ID value. + + + + + + Name of relevant publication. + + + + Name of relevant publication. + + + + + + Relevant URL for available information. + + + + Relevant URL for available information. + + + + + + An exponent of the unit, specified as powerNumerator and powerDenominator. + + + + An integer exponent of the unit. + + + + + An integer value divided into the powerNumerator to create a non integer exponent of a unit. For example 1/2. + + + + + + Prefix identifier; e.g., m, k, M, G. [Enumeration order is by prefix magnitude (Y to y) followed by binary prefixes.] + + + + Prefix identifier; e.g., m, k, M, G. [Enumeration order is by prefix magnitude (Y to y) followed by binary prefixes.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + URL to a representation of the unit or quantity in terms of the 7 SI base dimensions. + + + + URL to a representation of the unit or quantity in terms of the 7 SI base dimensions. + + + + + + + + Type for the unit container. + + + + + Element for describing units. Use in containers UnitSet or directly incorporate into a host schema. + + + + + + + Type for the unit. + + + + + Container for describing the system(s) of units. + + + + + + + + Container for defining derived units in terms of their root units. This allows a precise definition of a wide range of units. The goal is to improve interoperability among applications and databases which use derived units based on commonly encountered root units. + + + + + + + Element for descriptive information, including version changes to the unit. + + + + + + + + + + Used to indicate the version of the unit output from the Units Database. Changes in the time-stamp are made if a substantive change has been made to the unit, such as a change in the unit definition or changes in conversion factors. + + + + + Reference to a representation of the unit or quantity in terms of the 7 SI base dimensions. + + + + + + Type for the element for listing the unit code value from a specific code list. + + + + The code associated for this unit in a specific code list. + + + + + The name of the code list. + + + + + The version of the code list containing the unit code. + + + + + Suggested retrieval location for this version of the code list. + + + + + Organization responsible for publication and/or maintenance of the code list. + + + + + URI for organization responsible for the code list. + + + + + Primary language of the element and/or its attributes. [See RFC 4646, RFC 4647 and ISO 639.] + + + + + + Type for the container for defining derived units in terms of their root units. This allows a precise definition of a wide range of units. The goal is to improve interoperability among applications and databases which use derived units based on commonly encountered base units. + + + + + Element for a root unit (from an extensive enumerated list) allowing an optional prefix and power. E.g., mm^2 + + + + + Element for those special cases where the root unit needed is not included in the enumerated list in the above element. + + + + + + + Type for the element for a root unit (from an extensive enumerated list) allowing an optional prefix and power. E.g., mm^2 + + + + Unit identifier; the enumerated list is basically English unit names in lowercase, with a few upper case exceptions, e.g., 32F, mmHg, pH. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Prefix identifier; e.g., m, k, M, G. [Enumeration order is by prefix magnitude (Y to y) followed by binary prefixes.] + + + + + + + Type for the element for those special cases where the root unit needed is not included in the enumerated list in the above element. + + + + URI to identify the unit. + + + + + URI identifying the source and possibly the definition of the unit. + + + + + Optional unit annotation; e.g., a unit name if the unit identifier above is an uncommon code. + + + + + + + + + Type for the container for providing conversion information to other units. + + + + + Element for providing factors for a conversion equation from another unit; stem:[y = d + ((b / c) (x + a))]. Note: The related "conversion to" equation is a simple inversion of the above equation; i.e., stem:[x = ((c / b) (y - d)) - a]. + + + + + Element for describing a conversion that cannot be described by the linear expression in the element Float64ConversionFrom. + + + + + Element for providing conversion based on SOAP/WSDL calls to a remote server. + + + + + + + Type for the element for providing factors for a conversion equation from another unit; stem:[y = d + ((b / c) (x + a))] + + + + + + + + + Number to be added at the start of the conversion (prior to multiplication or division) [factor 'a' in equation]. + + + + + Indicates the position of the least +significant digit (in decimal) of +the initialAddend; the position of +this digit is given by ten to +additive inverse of this number. + + + + + Number by which to multiply sum of initial addend and initial value [factor 'b' in equation]. + + + + + Number of significant digits in the multiplicand value. + + + + + Divisor to be applied to the value at the same time as the multiplicand [factor 'c' in equation]. + + + + + Number of significant digits in the divisor value. + + + + + Number to be added at the end of the conversion [factor 'd' in equation]. + + + + + Indicates the position of the least +significant digit (in decimal) of +the finalAddend; the position of +this digit is given by ten to +additive inverse of this number. + + + + + Indicates if the conversion is exact. + + + + + + Type for the element for providing unit conversion information for conversions that are more complex than the Float64ConversionFrom linear equation. + + + + + Description of the conversion. + + + + + + + URL for external description of the conversion or for an online convertor. + + + + + + + Type for the element for providing unit conversion information for conversions that are more complex than the Float64ConversionFrom linear equation. + + + + + Description of the service. + + + + + + + + URL for external WSDL definition file. + + + + + + + Type for a set of counted items. + + + + + + + + Type for a single counted item. + + + + + + + + + + + + + + + Type for quantity container. + + + + + + + + Type for the quantity. + + + + + + Element containing various quantity symbols. + + + + + Element for specifying particular units associated with the quantity. + + + + + Element for descriptive information, including version changes to the quantity. + + + + + + + + + + Type of the quantity. For example base or derived. + + + + + + + + + + + + + + + Type for the dimension container. + + + + + Element to express a unit or quantity in terms of the SI base quantities length, mass, time, electric current, thermodynamic temperature, amount of substance, and luminous intensity. + + + + + + + Type for dimension. + + + + This unbounded sequence allows any order of any number of elements; e.g., L^1 · L^-1. + + + + + + + + + + + + Element containing the dimension of any item. Note: this element is meant to be used to allow counted items to be included in the dimensioning of a derived quantity, e.g., electrons per time; usage of this element does not conform to the SI description of the dimension of a quantity in terms of seven base quantities. + + + + + + + Boolean to designate that a quantity or unit is dimensionless. + + + + + + Type of the quantity length. + + + + Symbol of the quantity length. + + + + + + + Type of the quantity mass. + + + + Symbol of the quantity mass. + + + + + + + Type of the quantity time. + + + + Symbol of the quantity time. + + + + + + + Type of the quantity electric current. + + + + Symbol of the quantity electric current. + + + + + + + Type of the quantity thermodynamic temperature. + + + + Symbol of the quantity thermodynamic temperature. + + + + + + + Type of the quantity amount of substance. + + + + Symbol of the quantity amount of substance. + + + + + + + Type of the quantity luminous intensity. + + + + Symbol of the quantity luminous intensity. + + + + + + + Type of the quantity plane angle. + + + + Symbol of the quantity plane angle. + + + + + + + Type of the quantity represented by a counted item, e.g., electron + + + + Unique URL for identifying or describing the item. + + + + + Symbol for the item. + + + + + + + + Type for container for prefixes. + + + + + + + + Type for element for describing prefixes. Use in container PrefixSet. + + + + + + + + + The base of the prefix system, i.e., 10 (SI) or 2 (binary). + + + + + + + + + + + The exponential power of the prefix with relation to the base. + + + + + + + Type for name. Used for names in units, quantities, and prefixes. + + + + + + + + + + Type for unit system. + + + + Name of the unit system. For example, SI, inch-pound, CGS, and MKS. + + + + + Description of the unit relative to the unit system. Examples are SI_base and non-SI_not_acceptable. + + + + + + + Type for symbols. Used in units, quantities, and prefixes. + + + + + + + + Type of symbol representation. Examples include ASCII, unicode, HTML, and MathML. + + + + + + + + + + + + + + + + + + + + Type for notes. Used in units and conversion factors. + + + + + + + + + + Type for definition. + + + + + + + + + + + + Type for history. + + + + + + + + + + + + Type for remark. + + + + + + + + Primary language of the element and/or its attributes. [See RFC 4646, RFC 4647 and ISO 639.] + + + + + + + + Type for reference to a unit or quantity. + + + + URL to the reference item. + + + + + Name of the referenced item. + + + + + Primary language of the element and/or its attributes. [See RFC 4646, RFC 4647 and ISO 639.] + + + + diff --git a/sources/unitsml-xml-schema/sections/00-foreword.adoc b/sources/unitsml-xml-schema/sections/00-foreword.adoc new file mode 100644 index 0000000..b0c4217 --- /dev/null +++ b/sources/unitsml-xml-schema/sections/00-foreword.adoc @@ -0,0 +1,35 @@ + +.Foreword +The Calendaring and Scheduling Consortium ("`CalConnect`") is a global +non-profit organization with the aim to facilitate interoperability of +collaborative technologies and tools through open standards. + +CalConnect works closely with international and regional partners, +of which the full list is available on our website +(https://www.calconnect.org/about/liaisons-and-relationships). + +The procedures used to develop this document and those intended for its +further maintenance are described in the CalConnect Directives. + +In particular the different approval criteria needed for the different +types of CalConnect documents should be noted. This document was drafted in +accordance with the editorial rules of the CalConnect Directives. + +Attention is drawn to the possibility that some of the elements of this +document may be the subject of patent rights. CalConnect shall not be +held responsible for identifying any or all such patent rights. Details +of any patent rights identified during the development of the document +will be provided in the Introduction. + +//// +// TODO: re-enable when we finish the IPR policy +and/or on the CalConnect list of patent +declarations received (see www.calconnect.com/patents). +//// + +Any trade name used in this document is information given for the +convenience of users and does not constitute an endorsement. + +This document was prepared by Technical Committee +_{technical-committee}_. + diff --git a/sources/unitsml-xml-schema/sections/00-intro.adoc b/sources/unitsml-xml-schema/sections/00-intro.adoc new file mode 100644 index 0000000..c4b051a --- /dev/null +++ b/sources/unitsml-xml-schema/sections/00-intro.adoc @@ -0,0 +1,9 @@ +== Introduction + +The UnitsML XML Schema defines the structure and content of the +representation of UnitsML objects in XML. + +It is defined as an XML Schema definition (XSD) for use in XML +applications. The schema is intended to be used in conjunction with the +UnitsML specification, which defines the semantics of the UnitsML +vocabulary. diff --git a/sources/unitsml-xml-schema/sections/01-scope.adoc b/sources/unitsml-xml-schema/sections/01-scope.adoc new file mode 100644 index 0000000..9850c5e --- /dev/null +++ b/sources/unitsml-xml-schema/sections/01-scope.adoc @@ -0,0 +1,4 @@ +== Scope + +This document describes the UnitsML XML Schema (UnitsML XSD), which is an +XML Schema definition for the representation of UnitsML objects in XML. diff --git a/sources/unitsml-xml-schema/sections/02-normrefs.adoc b/sources/unitsml-xml-schema/sections/02-normrefs.adoc new file mode 100644 index 0000000..f53842b --- /dev/null +++ b/sources/unitsml-xml-schema/sections/02-normrefs.adoc @@ -0,0 +1,6 @@ +[bibliography] +== Normative references + +* [[[w3c_xmlschema,W3C xmlschema-1]]] +* [[[w3c_xmlschema-1,W3C xmlschema11-1]]] +* [[[w3c_xmlschema-2,W3C xmlschema11-2]]] diff --git a/sources/unitsml-xml-schema/sections/03-terms.adoc b/sources/unitsml-xml-schema/sections/03-terms.adoc new file mode 100644 index 0000000..05c991f --- /dev/null +++ b/sources/unitsml-xml-schema/sections/03-terms.adoc @@ -0,0 +1,48 @@ +== Terms and definitions + +=== unit + +standard quantity used to express a physical quantity + +=== basic unit + +unit not derived from other units + +=== composite unit + +unit derived from two or more basic units conjoined by multiplication or division + +=== prefix + +modifier to a unit with a fixed factor + +=== quantity + +type of measurement that is represented by a unit + +[example] +distance, moment of force, temperature, energy. + +=== dimension + +basic physical quantity that can be expressed in terms of fundamental +quantities + +[example] +length, mass, time, plane angle. + +=== unit name + +name of a unit + +=== unit symbol + +abbreviated representation of a unit + +=== unit reference + +reference identifier to a unit in a database + +=== unit dimensions + +fundamental quantities to which the unit applies diff --git a/sources/unitsml-xml-schema/sections/04-conventions.adoc b/sources/unitsml-xml-schema/sections/04-conventions.adoc new file mode 100644 index 0000000..5cfa8b5 --- /dev/null +++ b/sources/unitsml-xml-schema/sections/04-conventions.adoc @@ -0,0 +1,90 @@ +== Conventions + +=== General + +Elements and attributes defined in the UnitsML XML schema are described in +following clauses. + +Each element and attribute is described in a separate entry, with entries +arranged in alphabetical order. + +=== Element + +Each element entry contains the following information: + +* The XML Name (tag or generic identifier) of the element or attribute that is +used in UnitsML XML files. ++ +[example] +==== +`` +==== + +* The informational name of the element or attribute. ++ +[example] +==== +Unit +==== + +* A description of the element or attribute. ++ +[example] +==== +For the element ``: "Specifies a unit of measurement." +==== + +* A list of all of the attributes that may be applied to the element, with first +the attribute name and then the attribute's informal expanded name. Attribute +names are prefixed with an at sign (`@`). + +* The content model or type of the element's content. If the element has a type, +the type is given first, with a link to the type definition. If the element +does not have a type, the content model is described in detail, supporting +groups, sequences, choices, one of and any of. ++ +[example] +==== +string, integer, boolean, or a reference to a simple or complex type defined in +the schema. +==== + + +=== Attribute + +Each attribute entry contains the following information: + +* The XML Name of the attribute. ++ +[example] +==== +`@quantityType` +==== + +* The informational name of the attribute. ++ +[example] +==== +Quantity Type +==== + +* A description of the attribute +[example] +==== +Type of the quantity. +==== + +* The data type of the attribute's value. ++ +[example] +==== +string, integer, boolean, or a reference to a simple type defined in the schema. +==== + +* A list of all of the elements or groups of elements in which the attribute may +be used, with first the element name and then the element's informal +expanded name. Element names are not prefixed. + +* For each element or group of elements in which the attribute may be used, a +block of usage information with required or suggested values and other +information. diff --git a/sources/unitsml-xml-schema/sections/05-schema.adoc b/sources/unitsml-xml-schema/sections/05-schema.adoc new file mode 100644 index 0000000..0281ec0 --- /dev/null +++ b/sources/unitsml-xml-schema/sections/05-schema.adoc @@ -0,0 +1,26 @@ +== Schema + +The UnitsML XML schema is defined in the file `unitsml.xsd`, which is +included in the UnitsML distribution. + +The root element of the schema is ``, which contains all other +elements. + +The schema is defined using the W3C XML Schema Definition Language +(<>), and conforms to <> and +<>. + +The UnitsML XML schema may be used in the following ways: + +* To validate UnitsML XML documents, ensuring that they conform to the + structure and content rules defined in the schema. + +* To incorportate UnitsML XML into XML application schemas, allowing for the + integration of UnitsML data with other XML-based data formats. + +* To generate code or data structures in programming languages that + support XML schema, facilitating the processing of UnitsML XML + documents. + +The UnitsML XML schema is maintained by the CalConnect TC UNITS Technical +Committee, and is available from https://www.unitsml.org. diff --git a/sources/unitsml-xml-schema/sections/06-elements.adoc b/sources/unitsml-xml-schema/sections/06-elements.adoc new file mode 100644 index 0000000..a563486 --- /dev/null +++ b/sources/unitsml-xml-schema/sections/06-elements.adoc @@ -0,0 +1,9 @@ +== Elements + +[lutaml_xsd,schemas/unitsml-v1.0-csd04.xsd,schema,skip_rendering_of=annotation,include_path=templates] +---- +{% for item in schema.elements_sorted_by_name %} +include::../templates/_element.adoc[] + +{% endfor %} +---- diff --git a/sources/unitsml-xml-schema/sections/07-complex-types.adoc b/sources/unitsml-xml-schema/sections/07-complex-types.adoc new file mode 100644 index 0000000..81feb11 --- /dev/null +++ b/sources/unitsml-xml-schema/sections/07-complex-types.adoc @@ -0,0 +1,9 @@ +== Complex types + +[lutaml_xsd,schemas/unitsml-v1.0-csd04.xsd,schema,skip_rendering_of=annotation,include_path=templates] +---- +{% for item in schema.complex_types_sorted_by_name %} +include::../templates/_complex_type.adoc[] + +{% endfor %} +---- diff --git a/sources/unitsml-xml-schema/sections/08-attribute-groups.adoc b/sources/unitsml-xml-schema/sections/08-attribute-groups.adoc new file mode 100644 index 0000000..8c1e2a6 --- /dev/null +++ b/sources/unitsml-xml-schema/sections/08-attribute-groups.adoc @@ -0,0 +1,9 @@ +== Attribute groups + +[lutaml_xsd,schemas/unitsml-v1.0-csd04.xsd,schema,skip_rendering_of=annotation,include_path=templates] +---- +{% for item in schema.attribute_groups_sorted_by_name %} +include::../templates/_attribute_group.adoc[] + +{% endfor %} +---- diff --git a/sources/unitsml-xml-schema/sections/99-bibliography.adoc b/sources/unitsml-xml-schema/sections/99-bibliography.adoc new file mode 100644 index 0000000..f494396 --- /dev/null +++ b/sources/unitsml-xml-schema/sections/99-bibliography.adoc @@ -0,0 +1,2 @@ +[bibliography] +== Bibliography diff --git a/sources/unitsml-xml-schema/templates/_attribute_group.adoc b/sources/unitsml-xml-schema/templates/_attribute_group.adoc new file mode 100644 index 0000000..99a0691 --- /dev/null +++ b/sources/unitsml-xml-schema/templates/_attribute_group.adoc @@ -0,0 +1,72 @@ +{%# Documentation #%} + +{%liquid + assign item_attributes = item.attribute_elements + assign used_by_items = item.used_by +%} +{% capture docs %} +{% for paragraph in item.annotation.documentation %} +{{ paragraph.content }} + +{% endfor %} +{% endcapture %} + +[[xsd_{{item.name}}]] +=== `{{ item.name }}` + +==== Group + +{{ docs }} + +{% if used_by_items.size > 0 %} +This attribute group is used by: + +{% for used_by in used_by_items %} +{% capture description %} +{% for paragraph in used_by.annotation.documentation %} +{{ paragraph.content }} + +{% endfor %} +{% endcapture %} +@{{ used_by.name }}:: +{% if description %} ++ +-- +{{ description }} +-- +{% endif %} + +{% endfor %} +{% endif %} + +==== Attributes + +{% if item_attributes.size > 0 %} +{% for attribute in item_attributes %} +{% capture attribute_docs %} +{% for paragraph in attribute.annotation.documentation %} +{{ paragraph.content }} + +{% endfor %} +{% endcapture %} +`@{{ attribute.name | default: attribute.ref }}`:: {% if attribute.referenced_type %}`{{ attribute.referenced_type }}`{% endif %} `[{{ attribute.cardinality }}]` +{% if attribute_docs %} ++ +-- +{{ attribute_docs }} +-- +{% endif %} + +{% endfor %} +{% else %} +No attributes defined. +{% endif %} + +{%- capture xmlns -%}xmlns="http://www.w3.org/2001/XMLSchema" {% endcapture %} + +.XSD source of `<{{ item.name }}>` + +[source,xml] +----- +{{ item | to_xml_representation: skip_rendering_of | remove: xmlns }} +----- diff --git a/sources/unitsml-xml-schema/templates/_child_elements.adoc b/sources/unitsml-xml-schema/templates/_child_elements.adoc new file mode 100644 index 0000000..e46ee65 --- /dev/null +++ b/sources/unitsml-xml-schema/templates/_child_elements.adoc @@ -0,0 +1,20 @@ +{%- capture cardinality -%}{{ child.min_occurrences }}..{{ child.max_occurrences }}{%- endcapture -%} +{%- if child.sequence? -%} +{%- assign min_or_max_ocurrs = child.min_occurs | default: child.max_occurs -%} +{%- if min_or_max_ocurrs -%}{%- assign indent = " " %} + Start Sequence [{{ cardinality }}] +{%- endif -%}{%- for element in child.resolved_element_order %}{%- if element.annotation? or element.attribute? or element.attribute_group? -%}{%- continue -%}{%- else %} + {{ indent }}{% render "child_elements", child: element -%} +{%- endif -%} +{%- endfor %} +{%- if min_or_max_ocurrs %} + End Sequence +{%- endif -%} +{%- elsif child.any? -%} + Allow any elements from any namespace ({{ child.process_contents }} validation). [{{ cardinality }}] +{%- elsif child.simple_content? %} + {{ child.base_type }} +{%- else -%} +{%- assign element_name = child.ref | default: child.name -%} + <{{ element_name }}> ... [{{ cardinality }}] +{%- endif -%} \ No newline at end of file diff --git a/sources/unitsml-xml-schema/templates/_complex_type.adoc b/sources/unitsml-xml-schema/templates/_complex_type.adoc new file mode 100644 index 0000000..01dd6ad --- /dev/null +++ b/sources/unitsml-xml-schema/templates/_complex_type.adoc @@ -0,0 +1,139 @@ +{%# Documentation #%} +{%liquid + assign item_attributes = item.attribute_elements + assign item_children = item.child_elements + assign used_by_items = item.used_by + assign item_element_order = item.resolved_element_order + assign elements = item.direct_child_elements +%} +{% capture docs %} +{% for paragraph in item.annotation.documentation %} +{{ paragraph.content }} + +{% endfor %} +{% endcapture %} + +[[xsd_{{item.name}}]] +=== `{{ item.name }}` + +==== General + +{{ docs }} + +{% if used_by_items.size > 0 %} +This complex type is used by: + +{% for used_by in used_by_items %} +* {{ used_by.name }} (<>) + +{% endfor %} +{% endif %} + +==== Attributes + +{% if item_attributes.size > 0 %} +{% for attribute in item_attributes %} +{% capture attribute_docs %} +{% for paragraph in attribute.annotation.documentation %} +{{ paragraph.content }} + +{% endfor %} +{% endcapture %} + +`@{{ attribute.ref | default: attribute.name }}`:: {% if attribute.referenced_type %}`{{ attribute.referenced_type }}`{% endif %} `[{{ attribute.cardinality }}]` +{% if attribute_docs %} ++ +-- +{{ attribute_docs }} +-- +{% endif %} + +{% endfor %} +{% else %} +No attributes defined. +{% endif %} + +==== Content model + +{% comment %} +TODO: The "content model" section needs to describe sequence, anyOf, allOf, +choice, etc, in proper hierarchy. +{% endcomment %} + +{% if item_children.size > 0 %} + +{% for child in item_children %} +{% assign item_name = child.ref || child.name %} +{% if item_name %} +{% capture child_docs %} +{% for paragraph in child.annotation.documentation %} +{{ paragraph.content }} + +{% endfor %} +{% endcapture %} + +{{ item_name }}:: {% if child.referenced_type %}`{{ child.referenced_type }}`{% endif %} [{{ child.min_occurrences }}..{{ child.max_occurrences }}] +{% if child_docs %} ++ +-- +{{ child_docs }} +-- +{% endif %} + +{% else %} +{{ child }} + +{% endif %} +{% endfor %} +{% else %} +No child elements defined. +{% endif %} + + + +[example] +.Illustrative usage of `<{{ item.name }}>` +==== +[source,xml] +----- +<...{% for attr in item_attributes %} +{%- capture type %} +{%- if attr.referenced_type %} +{{- attr.referenced_type }} +{%- elsif attr.simple_type.restriction %} +{{- attr.simple_type.restriction.base }} (value comes from list: '{{ attr.simple_type.restriction.enumeration | map: "value" | join: "'|'" }}') +{%- elsif attr.simple_type.union %} +{%- assign union = attr.simple_type.union -%} +{% capture enums %} +{%- for u_s_type in union.simple_type -%} +[ {{ u_s_type.restriction.base }} (value comes from list: {{- u_s_type.restriction.enumeration | map: "value" | join: "'|'" -}}) ] +{%- endfor -%} +{% endcapture -%} +union of: [ {{ union.member_types }}, {{ enums }} ] +{%- endif %} +{%- endcapture %} + {{ attr.referenced_name }}="{{ attr.fixed | default: type }}" [{{ attr.cardinality }}] +{%- endfor -%} +{%- if elements.size > 0 -%} +{% if item_attributes.size > 0 %} +> +{%- else -%}>{% endif %} +{%- if item.mixed %} + +{%- endif -%}{%- for child in elements -%}{%- if child.annotation? or child.attribute? or child.attribute_group? -%}{%- continue -%}{%- else -%} +{% render "child_elements", child: child -%} +{% endif -%} +{% endfor %} + +{%- else %} +/> +{% endif %} +----- +==== +{%- capture xmlns -%}xmlns="http://www.w3.org/2001/XMLSchema" {% endcapture %} + +.XSD source of `<{{ item.name }}>` +[source,xml] +----- +{{ item | to_xml_representation: skip_rendering_of | remove: xmlns }} +----- diff --git a/sources/unitsml-xml-schema/templates/_element.adoc b/sources/unitsml-xml-schema/templates/_element.adoc new file mode 100644 index 0000000..7478905 --- /dev/null +++ b/sources/unitsml-xml-schema/templates/_element.adoc @@ -0,0 +1,136 @@ +{%# Documentation #%} +{%liquid + assign item_complex_type = item.referenced_complex_type + assign item_attributes = item.attributes + assign item_children = item.child_elements + assign used_by_items = item.used_by + assign elements = item_complex_type.direct_child_elements +%} +{% capture docs %} +{% for paragraph in item.annotation.documentation %} +{{ paragraph.content }} + +{% endfor %} +{% endcapture %} + +[[xsd_{{item.name}}]] +=== `<{{ item.name }}>` + +==== General + +{{ docs }} + +{% if used_by_items.size > 0 %} +This element is used by: + +{% for used_by in used_by_items %} +* {{ used_by.name }} (<>) + +{% endfor %} +{% endif %} + +==== Attributes + +{% if item_attributes.size > 0 %} +{% for attribute in item_attributes %} +{% capture attribute_docs %} +{% for paragraph in attribute.annotation.documentation %} +{{ paragraph.content }} + +{% endfor %} +{% endcapture %} +`@{{ attribute.name | default: attribute.ref }}`:: {% if attribute.referenced_type %}`{{ attribute.referenced_type }}`{% endif %} `[{{ attribute.cardinality }}]` +{% if attribute_docs %} ++ +-- +{{ attribute_docs }} +-- +{% endif %} + +{% endfor %} +{% else %} +No attributes defined. +{% endif %} + +==== Content model + +This element is specified the type {{ item.type }} (<>). + +{% if item_children.size > 0 %} + +{% for child in item_children %} +{% assign item_name = child.ref | default: child.name %} +{% if item_name %} +{% capture child_docs %} +{% for paragraph in child.annotation.documentation %} +{{ paragraph.content }} + +{% endfor %} +{% endcapture %} + +{{ item_name }}:: {% if child.referenced_type %}`{{ child.referenced_type }}`{% endif %} [{{ child.min_occurrences }}..{{ child.max_occurrences }}] +{% if child_docs %} ++ +-- +{{ child_docs }} +-- +{% endif %} + +{% else %} +{{ child }} + +{% endif %} +{% endfor %} + +{% else %} +No child elements defined. +{% endif %} + + +[example] +.Illustrative usage of `<{{ item.name }}>` +==== +[source,xml] +----- +<{{item.name}}{% for attr in item_attributes %} +{%- capture type %} +{%- if attr.referenced_type %} +{{- attr.referenced_type }} +{%- elsif attr.simple_type.restriction -%} +{{- attr.simple_type.restriction.base -}} (value comes from list: '{{ attr.simple_type.restriction.enumeration | map: "value" | join: "'|'" }}') +{%- elsif attr.simple_type.union -%} +{%- assign union = attr.simple_type.union -%} +{% capture enums %} +{%- for u_s_type in union.simple_type -%} +{% assign something = u_s_type.restriction %} +{{- u_s_type.restriction.enumeration | map: "value" | join: "'|'" -}} +{%- endfor -%} +{% endcapture %} +{{- union.member_types }} (value comes from list: {{ enums }}) +{%- endif %} +{%- endcapture %} + {{ attr.referenced_name }}="{{ attr.fixed | default: type }}" [{{ attr.cardinality }}] +{%- endfor -%} +{%- if elements.size > 0 -%} +{% if item_attributes.size > 1 %} +> +{%- else -%}>{% endif %} +{%- if item_complex_type.mixed %} + +{%- endif -%}{%- for child in elements -%}{%- if child.annotation? or child.attribute? or child.attribute_group? -%}{%- continue -%}{%- else -%} +{% render "child_elements", child: child -%} +{% endif -%} +{% endfor %} + +{%- else %} +/> +{% endif %} +----- +==== +{%- capture xmlns -%}xmlns="http://www.w3.org/2001/XMLSchema" {% endcapture %} + +.XSD source of `<{{ item.name }}>` +[source,xml] +----- +{{ item | to_xml_representation: skip_rendering_of | remove: xmlns }} +-----