-
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
Open
suleman-uzair
wants to merge
15
commits into
main
Choose a base branch
from
feature/unitsml_lutaml_xsd
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5079123
Added liquid templates utilizing 'lutaml_xsd' command
6f87860
Delete sources/unitsml_xsd_docs/document.html
suleman-uzair 470dad3
removed handcrafted xml
7afdfc4
used Lutaml::Xsd#to_xml method over handcrafted XML
5a37983
feat: update xsd document
ronaldtse 9a3379e
Changed filter calls to drop method calls
83ccf2f
moved from filter use to lutaml-xsd liquid methods
59102cc
updated complex type and element documents
f7afc1c
updated documents and removed unused liquid files
2280f89
updated file extensions and documents
a31f28d
Updated templates code and added a new partial
5337377
Updated document files about child elements rendering in elements and…
42d74fb
Updated example block for complex type and element
47a278c
updated used lutaml-xsd methods names
e557401
Updated doc files and branch names in Gemfile
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,16 @@ | ||
| source "https://rubygems.org" | ||
|
|
||
| gem "lutaml", | ||
| github: "lutaml/lutaml", | ||
| branch: "update/xsd_support_metanorma_plugin" | ||
| gem "lutaml-model", | ||
| github: "lutaml/lutaml-model", | ||
| branch: "update/liquid_element_order" | ||
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| [#top] | ||
| = XSD Templates | ||
|
|
||
| [lutaml_xsd, ../../unitsdb/unitsml-v1.0-csd04.xsd, schema] | ||
| ---- | ||
| == Elements | ||
|
|
||
| include::sources/_elements.adoc[] | ||
|
|
||
| == Complex Types | ||
|
|
||
| include::sources/_complex_type.adoc[] | ||
|
|
||
| == Attribute Groups | ||
|
|
||
| include::sources/_attribute_groups.adoc[] | ||
| ---- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| {% for attribute_group in schema.attribute_group %} | ||
|
|
||
| [#attribute_group_{{attribute_group.name}}] | ||
|
|
||
| === Attribute Group: *{{ attribute_group.name }}* | ||
|
|
||
| ==== **Used By** {{ schema | used_by: attribute_group | join: ", " }} | ||
|
|
||
| ==== Description pass:[{{ attribute_group.annotation.documentation.first.content }}] | ||
|
|
||
| .XML Instance Representation | ||
| [source, xml] | ||
| ----- | ||
| {%- for attr in attribute_group.attribute %} | ||
| {{ attr.name }}="{{ attr | attr_type: }}" [{{ attr | min_max_arg: }}] | ||
| {%- endfor %} | ||
| ----- | ||
|
|
||
| .Schema Component Representation | ||
| [source, xml] | ||
| ----- | ||
| <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" -%} | ||
| {%- 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 %}> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| {%- if simple_type %} | ||
| {%- render "sources/simple_type", simple_type: simple_type, element: element, indent: " " %} | ||
| </xsd:attribute> | ||
| {%- endif %} | ||
| {%- endif %} | ||
| {%- if attribute_group_drop %} | ||
| <xsd:attributeGroup{{ attribute_group_drop | attributes_xml_representation_for: }}/> | ||
| {%- endif %} | ||
| {%- endfor %} | ||
| </xsd:attributeGroup> | ||
| ----- | ||
|
|
||
| --- | ||
|
|
||
| {% endfor %} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| {% for complex_type in schema.complex_type %} | ||
|
|
||
| [#complex_type_{{complex_type.name}}] | ||
|
|
||
| === Complex Type: *{{ complex_type.name }}* | ||
|
|
||
| ==== Used By {{ schema | used_by: complex_type | join: ", " }} | ||
|
|
||
| Description pass:[{{ complex_type.annotation.documentation.first.content }}] | ||
|
|
||
| {% assign complex_type_element_order = complex_type | resolved_element_order: %} | ||
| {% assign complex_type_attributes = schema | attributes: complex_type -%} | ||
| {% assign elements = schema | child_elements: complex_type %} | ||
| .XML Instance Representation | ||
| [source, xml] | ||
| ----- | ||
| <...{{ complex_type_attributes | xml_representations: schema }} | ||
| {%- if elements.size > 0 -%}> | ||
| {%- for child in elements -%} | ||
| {% assign element_name = child.ref || child.name %} | ||
| {%- if element_name %} | ||
| <{{ element_name }}> ... </{{ element_name }}> {{ child | cardinality_representation: }} | ||
| {%- else %} | ||
| {{ child }} | ||
| {%- endif %} | ||
| {%- endfor %} | ||
| </...> | ||
| {%- else -%} | ||
| /> | ||
| {% endif %} | ||
| ----- | ||
|
|
||
| .Schema Component Representation | ||
| [source, xml] | ||
| ----- | ||
| <xsd:complexType name="{{ complex_type.name }}"> | ||
| {%- for object in complex_type_element_order %} | ||
| {%- assign sequence_drop = object | class_name_end_with: "::SequenceDrop" -%} | ||
| {%- assign attribute_drop = object | class_name_end_with: "::AttributeDrop" -%} | ||
| {%- assign simple_content_drop = object | class_name_end_with: "::SimpleContentDrop" -%} | ||
| {%- assign attribute_group_drop = object | class_name_end_with: "::AttributeGroupDrop" -%} | ||
| {%- if sequence_drop %} | ||
| <xsd:sequence{{ object | attributes_xml_representation_for: }}> | ||
| {%- for element in object.element %} | ||
| <xsd:element{{ element | attributes_xml_representation_for: }}/> | ||
| {%- endfor %} | ||
| {%- for any in object.any %} | ||
| <xsd:any{{ any | attributes_xml_representation_for: }}/> | ||
| {%- endfor %} | ||
| </xsd:sequence> | ||
| {%- endif %} | ||
| {%- if attribute_drop %} | ||
| <xsd:attribute{{ object | attributes_xml_representation_for: }}{% unless object.simple_type %}/{% endunless %}> | ||
| {%- if object.simple_type %} | ||
| {%- render "sources/simple_type", simple_type: object.simple_type, indent: " " %} | ||
| </xsd:attribute> | ||
| {%- endif %} | ||
| {%- endif %} | ||
| {%- if attribute_group_drop %} | ||
| <xsd:attributeGroup{{ object | attributes_xml_representation_for: }}/> | ||
| {%- endif %} | ||
| {%- if simple_content_drop %}{% assign simple_content_children = object | simple_content_children: %} | ||
| <xsd:simpleContent> | ||
| {%- for child in simple_content_children %} | ||
| {{ child }} | ||
| {%- endfor %} | ||
| </xsd:simpleContent> | ||
| {%- endif %} | ||
| {%- endfor %} | ||
| </xsd:complexType> | ||
| ----- | ||
|
|
||
| --- | ||
|
|
||
| {% endfor %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| {% for element in schema.element %} | ||
|
|
||
| [#element_{{element.name}}] | ||
| === Element: *{{ element.name }}* | ||
|
|
||
| ==== Type <<complex_type_{{element.type}}, {{ element.type }}>> | ||
| {% assign used_by_elements = schema | used_by: element %} | ||
| {% if used_by_elements.size > 0 %}==== *Used By* {{ used_by_elements | join: ", " }}{% endif %} | ||
|
|
||
| ==== Description *pass:[{{ element.annotation.documentation.first.content }}]* | ||
| {% assign element_attributes = schema | attributes: element %} | ||
| {% assign element_children = schema | child_elements: element %} | ||
|
|
||
| .XML Instance Representation | ||
| [source, xml] | ||
| ----- | ||
| <{{element.name}}{{ element_attributes | xml_representations: schema }} | ||
| {%- if element_children.size > 0 -%}> | ||
| {%- for child in element_children -%} | ||
| {% assign element_name = child.ref || child.name %} | ||
| {%- if element_name %} | ||
| <{{element_name}}> ... </{{ element_name }}> {{ child | cardinality_representation: }} | ||
| {%- else %} | ||
| {{ child }} | ||
| {%- endif %} | ||
| {%- endfor %} | ||
| </{{element.name}}> | ||
| {%- else -%} | ||
| /> | ||
| {% endif %} | ||
| ----- | ||
|
|
||
| .Schema Component Representation | ||
| [source, xml] | ||
| ----- | ||
| <xsd:element name="{{element.name}}" type="{{element.type}}" /> | ||
| ----- | ||
| --- | ||
|
|
||
| {% endfor %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| {%- assign simple_type_indent = indent | append: " " %} | ||
| {%- assign extended_indent = simple_type_indent | append: " " %} | ||
| {{indent}}<xsd:simpleType> | ||
| {%- if simple_type.restriction %} | ||
| {%- assign restriction = simple_type.restriction %} | ||
| {{simple_type_indent}}<xsd:restriction base="{{ restriction.base }}"> | ||
| {%- for enumeration in restriction.enumeration %} | ||
| {{extended_indent}}<xsd:enumeration value="{{ enumeration.value }}"/> | ||
| {%- endfor %} | ||
| {{simple_type_indent}}</xsd:restriction> | ||
| {%- elsif simple_type.union %} | ||
| {%- assign union = simple_type.union %} | ||
| {{simple_type_indent}}<xsd:union memberTypes="{{ union.member_types }}"{% unless union.simple_type %}/{% endunless %}> | ||
| {%- for union_simple_type in union.simple_type %} | ||
| {%- render "sources/simple_type", simple_type: union_simple_type, indent: extended_indent %} | ||
| {{simple_type_indent}}</xsd:union> | ||
| {%- endfor %} | ||
| {%- endif %} | ||
| {{indent}}</xsd:simpleType> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.