-
Notifications
You must be signed in to change notification settings - Fork 0
Unitsml schema template using Lutaml::Xsd and Metanorma command #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Added complex_type and attribute_groups templates and added simple_type as partial
|
@suleman-uzair thanks! Please remove document.html from the latest commit since we shouldn't keep artifacts in the repo. Also, the document.adoc requires some metadata, please copy the structure from say, sources/unitsdb/document.adoc. Thanks! |
| <xsd:attributeGroup name="{{attribute_group.name}}"> | ||
| {%- assign element_order = attribute_group | resolved_element_order: %} | ||
| {%- for element in element_order %} | ||
| {%- assign attribute_drop = element | class_name_end_with: "::AttributeDrop" -%} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want any "Ruby class names" in Liquid... The attribute variable here should already be the Drop object. Every XSD element should be here as a Drop object.
| {%- assign attribute_group_drop = element | class_name_end_with: "::AttributeGroupDrop" -%} | ||
| {%- assign simple_type = element.simple_type %} | ||
| {%- if attribute_drop %} | ||
| <xsd:attribute{{ element | attributes_xml_representation_for: }}{% unless simple_type %}/{% endunless %}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to handcraft XML elements here? We actually want the source directly, which should be provided by the drop (add a "source" method?).
You can see how Expressir stores the source of the parsed content and provides it through the method.
e0fa84b to
e9215dd
Compare
|
@suleman-uzair I have updated the document and there are many things to be changed in the way it works. There is a problem that needs to be comprehensively fixed in this implementation (the combined implementation) that the Liquid code "assumes" Metanorma syntax. There should be no Metanorma AsciiDoc syntax inside Lutaml or Liquid. For example, items in
Remove non-default Liquid::Drop implementations
The We need to remove all (if not most) custom Drop classes. If any is needed, they should be defined using the Remove Liquid filters unless absolutely necessaryWe do not want to add Liquid filters because they are difficult to use -- the user does not know what data types a filter acts on and what output the filter provides. Always prefer Drop methods over custom filters. e.g. Should just be: {{ attr | min_max_arg }}Should just be: And any of these need to be documented. No Metanorma-related assumptions in Liquid
When you compile the document, you can see there are cross-references called from the Liquid filter that assume the patterns of These all need to be removed. Missing XML Schema element relationships: groups, sequence, any of, orderUnitType contains a <xsd:complexType name="UnitType">
<xsd:annotation>
<xsd:documentation>Type for the unit.</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element ref="UnitSystem" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>Container for describing the system(s) of units.</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element ref="UnitName" maxOccurs="unbounded"/>
<xsd:element ref="UnitSymbol" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="CodeListValue" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="RootUnits" minOccurs="0">
<xsd:annotation>
<xsd:documentation>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.</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element ref="Conversions" minOccurs="0"/>
<xsd:element ref="QuantityReference" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="UnitVersionHistory" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>Element for descriptive information, including version changes to the unit.</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element ref="UnitDefinition" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="UnitHistory" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="UnitRemark" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute ref="xml:id" use="required"/>
<xsd:attribute name="timeStamp" type="xsd:dateTime">
<xsd:annotation>
<xsd:documentation>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.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attributeGroup ref="dimensionURL">
<xsd:annotation>
<xsd:documentation>Reference to a representation of the unit or quantity in terms of the 7 SI base dimensions.</xsd:documentation>
</xsd:annotation>
</xsd:attributeGroup>
</xsd:complexType>
Missing simpleType/enumerations
<xsd:complexType name="EnumeratedRootUnitType">
<xsd:annotation>
<xsd:documentation>Type for the element for a root unit (from an extensive enumerated list) allowing an optional prefix and power. E.g., mm^2</xsd:documentation>
</xsd:annotation>
<xsd:attribute name="unit" use="required">
<xsd:annotation>
<xsd:documentation>Unit identifier; the enumerated list is basically English unit names in lowercase, with a few upper case exceptions, e.g., 32F, mmHg, pH.</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:restriction base="xsd:token">
<xsd:enumeration value="meter"/>
<xsd:enumeration value="gram"/>
<xsd:enumeration value="second"/>
<xsd:enumeration value="ampere"/>
<xsd:enumeration value="kelvin"/>
<xsd:enumeration value="mole"/>
<xsd:enumeration value="candela"/>
...
While the rendered sample XML does display the list using this: [example]
.Illustrative usage of `<{{ item.name }}>`
====
[source,xml]
-----
<{{item.name}}{{ item_attributes | xml_representations: schema }}
{%- if item_children.size > 0 -%}>
{%- for child in item_children -%}
{% assign item_name = child.ref || child.name %}
{%- if item_name %}
<{{item_name}}> ... </{{ item_name }}> {{ child | cardinality_representation: }}
{%- else %}
{{ child }}
{%- endif %}
{%- endfor %}
</{{item.name}}>
{%- else -%}
/>
{% endif %}
-----
====
But this is not what we want. The The pattern of Liquid template FileSystem not setupIn the Please refer to how For example, if you extract the attribute rendering code to share amongst the 3 templates, this will fail: With: Because the Liquid FileSystem root is assumed to be
|
|
@suleman-uzair can you please help copy/paste the tickets to the correct repositories for individual implementation? Thanks. Please also message me so we can resolve this interactively, thanks! |
e9215dd to
5a37983
Compare
@ronaldtse, I have created the following issues in their respective repositories:
Additionally, please review the following PR for the mentioned issue: |










This PR adds
adocandliquidfiles for Unitsml schema documentation generation viaLutaml::Xsdgem.closes #5