Metanorma: Aequitate Verum

Rendering GML Dictionary objects

Author’s picture Kwan Koon Wa on 21 Aug 2024

Introduction

New Metanorma work for the MLIT Project PLATEAU yielded a new command now generally available to all Metanorma users.

The lutaml_gml_dictionary is a command for rendering the Geography Markup Language (GML) Dictionary object type.

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)

GML’s Dictionary is a GML object type that provides a mechanism for defining terms and their meanings in a GML application schema. It is used to define terms and their meanings in a GML application schema, providing a mechanism for defining terms and their meanings in a GML application schema.

Data encoding samples

In the following examples we will refer to GML dictionary files from the Japan "i-Urban Revitalization" ("i-UR") project i-UR XML library 3.1.

Example 1. Snippet of a GML dictionary from i-UR 3.1 Building_class.xml
<?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>

Command

The lutaml_gml_dictionary 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 lutaml_gml_dictionary by specifying the path of the GML Dictionary file and the liquid template.

Syntax:

Using lutaml_gml_dictionary with external template
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.

Example 2. Rendering the GML Dictionary from Building_class.xml
lutaml_gml_dictionary::/path/to/Building_class.xml[...]
{path-to-template}

specifies the liquid template.

Example 3. 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::Drop object inside Liquid template.

Example 4. 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:

Using lutaml_gml_dictionary with supplied block as template
[lutaml_gml_dictionary,"{path-to-dictionary}",context={context-var}]
--
// content of Liquid template
--
Example 5. Using lutaml_gml_dictionary with a file path to the 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 dictionaryEntry objects

name

Name of the dictionaryEntry object (name)

description

Description of the dictionaryEntry object (description)

Example 6. GmlDictionaryDrop object of Building_class.xml

The GmlDictionaryDrop object of the Building_class.xml file will provide:

  • The name of the GML Dictionary is Building_class.

  • The file_name of the GML Dictionary is Building_class.xml.

  • It has five dictionary entries:

    • The name and description of the first dictionary_entry are 3001 and 普通建物.

Here’s an example of a Liquid template file to show the GML Dictionary in a table.

Example 7. Liquid template that renders the GML Dictionary into 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

Description

3001

普通建物

3002

堅ろう建物

3003

普通無壁舎

3004

堅ろう無壁舎

3000

分類しない建物

Conclusion

Questions or suggestions, please feel free to file an issue at the metanorma-plugin-lutaml repository at GitHub!