"Seegrid will be due for a migration to confluence on the 1st of August. Any update on or after the 1st of August will NOT be migrated"

Proposed new GML encoding rules

Contents

Related pages



Proposals for new GML encoding rules.

These leverage the UML tagged value, since this is the extension point used for implementation-specific directives.

UML Redefine - implemented in FullMoon

Requirement

In a UML model, a class-attribute or association-role may have the same name as an attribute or role inherited from a parent classifier, in which case the element is interpreted as re-defining the attribute or role. Most commonly this mechanism is used to change the type of an attribute, or the target of an association. (See example diagram below.) In UML there are no constraints on redefinitions, though for conceptual consistency the redefined property will usually be related to the parent, often a specialization.

XML implementation

XML Schema

The W3C XML Schema restriction element, possibly combined with redefine element, may be used to implement a redefinition in some circumstances. However, this mechanism may only be used if
  1. the type of the redefined element is derived from the type of the original element
  2. the redefined components are in the same XML namespace as the original.
Following the ISO 19118/19136 UML profile this means that the class with a redefined property must be contained in the same UML package stereotyped «Application Schema» as the class from which the property is inherited.

[This is because, in the XML schema implementation following the ISO 19136 encoding rules, a property is encoded as a local element declaration. It is not possible within a schema to make a specific reference to a locally declared element in another namespace, so it is not possible to redefine it or to declare a new XML element to be in its substitution group across namespace boundaries using W3C XML Schema mechanisms. ]

Hence, in general W3C XML Schema mechanisms do not support implementation of a redefine, so another pattern must be used.

Schematron

Schematron may express constraints to the XML encoding that are consistent with the UML redefinition. Note that combination of Schematron with the W3C XML Schema declarations is limited to cases where instances of the redefined properties are still valid against the original schema definitions. For example, a Schematron rule may limit the type of a property to a subset of that allowed by the parent, by selecting a member of a substitution group, or a derived type. However, this is likely to be the most common case.

The case where a redefine fixes an attribute type or association target can be expressed using a Schematron assert element. For example

<sch:rule context="nns:Class2">   <!-- rule applies to XML element that implements the host class -->
   <sch:assert test="ons:roleA/ens:Class4 or empty(ons:roleA/*)"
                   >roleA must contain either Class4 or nothing</sch:assert>
</sch:rule>

To complete a GML-conformant XML encoding using this mechanism, the usual declaration of a local "property" element in the content model of the XML element corresponding to the specialized class in the new namespace must be suppressed.

New tagged-value "ownedBy"

XML Schema implementations of application schemas may be generated by an automated encoder that has access to the UML model.

If the encoder functions with knowledge of the complete model, with details of all dependencies, then the fact that an attribute or association role is a redefinition may be detected automatically.

However, if the encoder works on an XMI representation of an «Application Schema» Package, the internal details in packages outside this one are not available. Such details include the attributes and association roles owned by classes in the external packages. Hence, it is not possibly to automatically detect the fact that an attribute or association role in the current package is a redefinition of one in an external package. So it is necessary for the encoder to be alerted using another mechanism.

We propose use of a tagged value on the redefined attribute or association role:
  • tag="ownedBy" value="PackageName"

PackageName indicates the «Application Schema» Package that owns the original attribute or association, and provides the XML namespace for the XML element that implements the property (undetectable from the XMI).

N.B. If the class that owns the original property is in the same package as the class that owns the redefined property, the value of "ownedBy" shall be set to "local".

This tagged value may be set manually, by the schema designer who will be aware that "redefine" is intended. UML automation might be used to detect the fact that a property is a redefinition, and either create the tagged value automatically or prompt the designer to create it.

Encoding rule

If
  • an attribute or association role ("property") foo has a tagged value ownedBy="OriginalPackage",
  • foo is owned by a class Bar which has the stereotype «Type», «FeatureType», or «DataType»
where
  • foo and Bar are owned by NewPackage, which has targetNamespace="New_namespace"
  • foo has the type/target-class Baz owned by ExternalPackage, which has targetNamespace="External_namespace"
  • OriginalPackage identifies a package which has targetNamespace="Original_namespace"
then
  1. do not generate an XML element for foo in the content model for Bar
  2. and one of
    • if foo does not carry a tagged value inlineOrByReference or the tagged value inlineOrByReference="inlineOrByReference" (default), and Baz has the stereotype «Type» or «FeatureType», generate a Schematron assert statement as follows
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
   <sch:title>Schematron constraints for Bar</sch:title> 
   <sch:ns prefix="sch" uri="http://purl.oclc.org/dsdl/schematron"/> 
   <sch:ns prefix="ons" uri="Original_namespace"/> 
   <sch:ns prefix="nns" uri="New_namespace"/> 
   <sch:ns prefix="ens" uri="External_namespace"/> 
   <sch:pattern name="Property redefined">
      <sch:rule context="//nns:Bar">   
         <sch:assert test="ons:foo/ens:Baz or (empty(ons:foo/*) and ons:foo/@xlink:href)"
                      >foo must contain either Baz or nothing (and carry an xlink:href instead)</sch:assert>
      </sch:rule>
   </sch:pattern>
</sch:schema>
    • if Baz has the stereotype «Union» and the members of the union class are ens1:Baz1, ens2:Bz2, ens3:Baz3 etc, the sch:assert must test that the target is a member of the union, i.e. generate a Schematron assert statement as follows
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
   <sch:title>Schematron constraints for Bar</sch:title> 
   <sch:ns prefix="sch" uri="http://purl.oclc.org/dsdl/schematron"/> 
   <sch:ns prefix="ons" uri="Original_namespace"/> 
   <sch:ns prefix="nns" uri="New_namespace"/> 
   <sch:ns prefix="ens1" uri="External_namespace1"/> 
   <sch:ns prefix="ens2" uri="External_namespace2"/> 
   <sch:ns prefix="ens3" uri="External_namespace3"/> 
   <sch:pattern name="Property redefined">
      <sch:rule context="//nns:Bar">   
         <sch:assert test="ons:foo/ens1:Baz1 or ons:foo/ens2:Baz2 or ons:foo/ens3:Baz3
             or (empty(ons:foo/*) and ons:foo/@xlink:href)"
             >foo must contain either a member of Baz or nothing (and carry an xlink:href instead)</sch:assert>
      </sch:rule>
   </sch:pattern>
</sch:schema>
    • if Baz has the stereotype «Enumeration» or «CodeList» and the members of the enumeration or codelist are string1, string2, string3 etc, and asDictionary="false" or is not present, generate a Schematron assert statement as follows
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
   <sch:title>Schematron constraints for Bar</sch:title> 
   <sch:ns prefix="sch" uri="http://purl.oclc.org/dsdl/schematron"/> 
   <sch:ns prefix="ons" uri="Original_namespace"/> 
   <sch:ns prefix="nns" uri="New_namespace"/> 
   <sch:pattern name="Property redefined">
      <sch:rule context="//nns:Bar">   
         <sch:assert test="ons:foo/text() = 'string1' or ons:foo/text() = 'string2' or ..."
                      >foo must contain a member of Baz</sch:assert>
      </sch:rule>
   </sch:pattern>
</sch:schema>
    • if Baz has the stereotype «CodeList» and the members of the enumeration or codelist are string1, string2, string3 etc, and asDictionary="true", and codeSpace="euri" generate a Schematron assert statement as follows
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
   <sch:title>Schematron constraints for Bar</sch:title> 
   <sch:ns prefix="sch" uri="http://purl.oclc.org/dsdl/schematron"/> 
   <sch:ns prefix="ons" uri="Original_namespace"/> 
   <sch:ns prefix="nns" uri="New_namespace"/> 
   <sch:pattern name="Property redefined">
      <sch:rule context="//nns:Bar">
         <sch:assert test="ons:foo/@codeSpace = 'euri'"
                      >foo must select a member of the dictionary euri</sch:assert>
      </sch:rule>
   </sch:pattern>
</sch:schema>
    • if the tagged value inlineOrByReference="inline", or if Baz has the stereotype «DataType», generate a Schematron assert statement as follows
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
   <sch:title>Schematron constraints for Bar</sch:title> 
   <sch:ns prefix="sch" uri="http://purl.oclc.org/dsdl/schematron"/> 
   <sch:ns prefix="ons" uri="Original_namespace"/> 
   <sch:ns prefix="nns" uri="New_namespace"/> 
   <sch:ns prefix="ens" uri="External_namespace"/> 
   <sch:pattern name="Property redefined">
      <sch:rule context="//nns:Bar">   
         <sch:assert test="ons:foo/ens:Baz">foo must contain Baz</sch:assert>
      </sch:rule>
   </sch:pattern>
</sch:schema>
    • if the tagged value inlineOrByReference="byReference", generate a Schematron assert statement as follows
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
   <sch:title>Schematron constraints for Bar</sch:title> 
   <sch:ns prefix="sch" uri="http://purl.oclc.org/dsdl/schematron"/> 
   <sch:ns prefix="ons" uri="Original_namespace"/> 
   <sch:ns prefix="nns" uri="New_namespace"/> 
   <sch:ns prefix="ens" uri="External_namespace"/> 
   <sch:pattern name="Property redefined">
      <sch:rule context="//nns:Bar">   
         <sch:assert test="empty(ons:foo/*) and ons:foo/@xlink:href"
                      >foo must contain nothing (and carry an xlink:href instead)</sch:assert>
      </sch:rule>
   </sch:pattern>
</sch:schema>

Should the generated Schematron be embedded in the <appinfo> element of the element declaration, or saved in a separate document?

Dictionaries - implemented in FullMoon

If a class stereotyped «CodeList» carries the tag asDictionary="true", it is implemented as a gml:Dictionary instance, instead of as an XML Schema union (of an enumeration + wildcard). In order to support fully automated encoding, values for the codeSpace, dictionary identifier, and a stem for definition identifiers are required.

The following additional tagged values are proposed to support this:
codeSpace=anyURI
dictionaryIdentifier=anyURI
memberIdentifierStem=anyURI 

The following example illustrates the encoding pattern:

Heaviness14.png

is implemented as
<gml:Dictionary xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/gml.xsd" gml:id="Heaviness">
    <gml:name codeSpace="http://uri.my.big.org">urn:test:conceptScheme:ORG:Heaviness:2008</gml:name>
    <gml:name>Heaviness</gml:name>
    <gml:dictionaryEntry>
        <gml:Definition gml:id="feather">
            <gml:description>featherweight option</gml:description>
            <gml:name codeSpace="http://uri.my.big.org">urn:test:concept:ORG:Heaviness:2008:feather</gml:name>
            <gml:name>feather</gml:name>
        </gml:Definition>
    </gml:dictionaryEntry>
    <gml:dictionaryEntry>
        <gml:Definition gml:id="light">
            <gml:description>light option</gml:description>
            <gml:name codeSpace="http://uri.my.big.org">urn:test:concept:ORG:Heaviness:2008:light</gml:name>
            <gml:name>light</gml:name>
        </gml:Definition>
    </gml:dictionaryEntry>
    <gml:dictionaryEntry>
        <gml:Definition gml:id="black-hole">
            <gml:description>How heavy do you want it?</gml:description>
            <gml:name codeSpace="http://uri.my.big.org">urn:test:concept:ORG:Heaviness:2008:black-hole</gml:name>
            <gml:name>black-hole</gml:name>
        </gml:Definition>
    </gml:dictionaryEntry>
    <gml:dictionaryEntry>
        <gml:Definition gml:id="heavy">
            <gml:description>heavy option</gml:description>
            <gml:name codeSpace="http://uri.my.big.org">urn:test:concept:ORG:Heaviness:2008:heavy</gml:name>
            <gml:name>heavy</gml:name>
        </gml:Definition>
    </gml:dictionaryEntry>
</gml:Dictionary>

Association classes - not yet implemented in FullMoon

An association class may be mapped into an equivalent intermediate class. See the following diagrams:

  • Association class example:
    AssociationClass.png

  • Intermediate class equivalents to association class:
    IntermediateClass.png

The encoding rule is to process to perform the mapping and then encode the model in the standard manner.

Constraints - not yet implemented in FullMoon

Requirement

UML constraints may be provided for any element in a UML model, to express model requirements that cannot be encoded using the standard UML language. They may be expressed in OCL, in informal text, or using a formal text-based language.

The only normative instruction in ISO 19136 concerning UML constraints is E.2.1.1.6 OCL constraints which states "All OCL constraints are ignored." In the XML context, Schematron is the most widely used constraint language. While there are several references to the use of Schematron constraints in XML implementations, there is no mechanism for these to be either generated from- or recorded in- the UML representation of an application schema.

The OGC OWS-5 project produced a report showing how some commonly used OCL could be mapped into Schematron.

Here we propose a simple mechanism to allow schematron-encoded constraints to be maintained as part of a UML model.

New tagged value - "schematron"

This tagged value may be applied to a package, class, attribute or association-end. Its value shall be a Schematron assert or report element (ISO/IEC 19757-3:2006).

Or maybe just put a sch:assert or sch:report in the UML constraint?

Implementation

In the encoded schema, the Schematron assert or report element shall be included in a Schematron rule whose context is the XML path to the instance resulting from encoding the UML context, using the following pattern:

  • if the context is a package, the value of the sch:rule/@context shall be the (any element in the) XML namespace spcified by the targetNamespace tagged value of the containing package stereotyped «Application Schema»
  • if the context is a class, the value of the sch:rule/@context shall be the XML element corresponding to the encoded class
  • if the context is an attribute or association end, the value of the sch:rule/@context shall be the XML element corresponding to the encoded property in its class context

 
Topic attachments
I Attachment Action Size Date Who Comment
AssociationClass.pngpng AssociationClass.png manage 11.0 K 19 Dec 2008 - 10:46 SimonCox Association class example
IntermediateClass.pngpng IntermediateClass.png manage 11.6 K 19 Dec 2008 - 10:46 SimonCox Intermediate class equivalents to association class
UML_example.pngpng UML_example.png manage 28.5 K 19 Feb 2008 - 14:24 SimonCox UML showing new tags to support redefine and constraints
Topic revision: r25 - 19 Oct 2010, UnknownUser
 

Current license: All material on this collaboration platform is licensed under a Creative Commons Attribution 3.0 Australia Licence (CC BY 3.0).