Rendering GML Dictionary objects
Geography Markup Language (GML)
Geography Markup Language (GML) is an XML-based language developed by the Open Geospatial Consortium (OGC) used for describing geographic features and their attributes, providing a standard way to represent and exchange geographic data between different systems.
The latest version, GML 3.2, has been standardized as ISO 19136:2007, Geographic information -- Geography Markup Language (GML)
A GML Dictionary is a GML object that provides a mechanism for defining terms and their meanings in a GML application schema.
The `lutaml_gml_dictionary` command
The lutamlgmldictionary is a command for rendering the GML Dictionary object type.
The following dictionary sample is taken from the Japan "i-Urban Revitalization" (i-UR) project i-UR XML library 3.1.
<?xml version="1.0" encoding="UTF-8"?>
<gml:Dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gml="http://www.opengis.net/gml" xsi:schemaLocation="http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/profiles/SimpleDictionary/1.0.0/gmlSimpleDictionaryProfile.xsd" gml:id="cl_c9fa7a39-966f-4ee4-8102-91fb15ad2dd3">
<gml:name>Building_class</gml:name>
<gml:dictionaryEntry>
<gml:Definition gml:id="Building_class_1">
<gml:description>普通建物</gml:description>
<gml:name>3001</gml:name>
</gml:Definition>
</gml:dictionaryEntry>
<gml:dictionaryEntry>
<gml:Definition gml:id="Building_class_2">
<gml:description>堅ろう建物</gml:description>
<gml:name>3002</gml:name>
</gml:Definition>
</gml:dictionaryEntry>
<gml:dictionaryEntry>
<gml:Definition gml:id="Building_class_3">
<gml:description>普通無壁舎</gml:description>
<gml:name>3003</gml:name>
</gml:Definition>
</gml:dictionaryEntry>
<gml:dictionaryEntry>
<gml:Definition gml:id="Building_class_4">
<gml:description>堅ろう無壁舎</gml:description>
<gml:name>3004</gml:name>
</gml:Definition>
</gml:dictionaryEntry>
<gml:dictionaryEntry>
<gml:Definition gml:id="Building_class_5">
<gml:description>分類しない建物</gml:description>
<gml:name>3000</gml:name>
</gml:Definition>
</gml:dictionaryEntry>
</gml:Dictionary>The lutamlgmldictionary command allows you to iterate this dictionary and pass it to a Liquid template for rendering.
The Liquid template can be specified as a block or as a file path to an external file.
To render the GML Dictionary, you can use lutamlgmldictionary by specifying the path of the GML Dictionary file and the liquid template.
Syntax:
lutaml_gml_dictionary::{path-to-dictionary}[template={path-to-template},context={context-var}]The command accepts the options listed below:
- {path-to-dictionary}
- specifies the path of XML file of the GML Dictionary.Rendering the GML Dictionary from `Building_class.xml`
lutaml_gml_dictionary::/path/to/Building_class.xml[...] - {path-to-template}
- specifies the Liquid template.Rendering the GML Dictionary using an external Liquid template
lutaml_gml_dictionary::/path/to/Building_class.xml[template="/path/to/template.liquid",...] context={dict}- define the context in the template. The context is used to access the
Liquid::Dropobject inside the Liquid template.Rendering the GML Dictionary with the context object set to `dict`lutaml_gml_dictionary::/path/to/Building_class.xml[template="/path/to/template.liquid",context=dict]
Alternatively, it can be specified as a block.
Syntax:
[lutaml_gml_dictionary,"{path-to-dictionary}",context={context-var}]
--
// content of Liquid template
--[lutaml_gml_dictionary,"/path/to/dictionary.xml",context=dict]
--
{% capture link %}https://www.test.com/{{ dict.file_name }}{% endcapture %}
[cols="3a,22a"]
|===
| File Name | {{ dict.file_name }}
h| URL | {{ link }}
h| Code h| Description
{% for entry in dict.dictionary_entry %}
| {{ entry.name }} | {{ entry.description }}
{% endfor %}
|===
--Liquid template and context object
Internally, the GML Dictionary object is passed into the Liquid template using a Liquid::Drop model named GmlDictionaryDrop.
GmlDictionaryDrop has the following attributes:
name- Name of the GML Dictionary
file_name- File name of the GML Dictionary file
dictionary_entry- Array of
dictionaryEntryobjectsname- Name of the
dictionaryEntryobject (name) description- Description of the
dictionaryEntryobject (description)
The GmlDictionaryDrop object of the Building_class.xml file will provide:
- The
nameof the GML Dictionary isBuilding_class. - The
file_nameof the GML Dictionary isBuilding_class.xml. - It has five dictionary entries:
- The
nameanddescriptionof the firstdictionary_entryare3001and普通建物.
- The
Here's an example of a Liquid template file to show the GML Dictionary in a table.
This template:
[cols="3a,22a"]
|===
| Name | {{ dict.file_name }}
h| Code h| Description
{% for entry in dict.dictionary_entry %}
| {{ entry.name }} | {{ entry.description }}
{% endfor %}
|===Renders the GML Dictionary into the following table:
| Name | Building_class.xml |
| Code h | Description |
| 3001 | 普通建物 |
| 3002 | 堅ろう建物 |
| 3003 | 普通無壁舎 |
| 3004 | 堅ろう無壁舎 |
| 3000 | 分類しない建物 |
Suggestions
For questions or suggestions, please feel free to file an issue at the metanorma-plugin-lutaml repository at GitHub!