ShapeChange

ShapeChange is an Open-Source Java tool that derives XML Schemas from UML application schemas by applying certain encoding rules. The following encoding rules are supported by ShapeChange:

  • GML 3.2.1 encoding rule for GML application schemas (also allows for deriving GML 3.1.1 application schemas)

  • GML 3.3 extensions

  • ISO/TS 19139 encoding rule

  • INSPIRE encoding rule.

  • CityGML ADEs

  • An extension supports the generation of a Schematron schema from OCL constraints in an application schema.

../../_images/image61.png

Requirements for deriving GML Application Schemas with ShapeChange

The following are the key requirements for creating GML Application Schemas with ShapeChange

  1. The UML Models must be defined using Enterprise Architect.

  2. The UML models must be defined using the concepts and stereotypes from ISO 19103, ISO 19109, and ISO 19136 Annex E, which includes the following:

  • A suitable UML profile containing the concepts and stereotypes from these ISO standards must be applied to the UML model.

  • The stereotypes must provide tagged values according to ISO 19136 Annex E which contain additional information for the encoding.

Connecting ShapeChange with your Enterprise Architect

When using your personal systems

Please check if your ShapeChange installation can recognize and read your Enterprise Architect files by checking if the file ‘SSJavaCOM64.dll / SSJavaCom.dll’ exists in your Windows folder.

  • Go to C: Drive > Windows > SysWOW64 > SSJavaCOM64.dll (For x64 systems)

(OR)

  • Check in C: Drive > Windows > System32 > SSJavaCom.dll (For x32 systems)

If the .dll files exist, you are good to go. If they do not exist, you need to copy them from the EA installation folder to the Windows folder.

  • Go to C: Drive > Program Files > Sparx Systems > EA > JavaAPI > SSJavaCOM64.dll / SSJavaCom.dll.

Note

In the JavaAPI files, you will find both the x64 and x32 bit versions. Copy and paste either of them in the respective Windows folders (as shown above) depending on the configuration of the CPU.

Stereotypes to be used in the UML Model

The following stereotypes are important to create a consistent and valid xsd file from a UML Diagram. These elements should be adapted in the UML diagram in Enterprise Architect and is explained below.

<<Application Schema>>

  • Denotes an application schema according to ISO 19109.

  • One XML Schema document is generated for every package marked with the stereotype «Application Schema».

  • The tagged values in green - xsdDocument, targetNamespace, xmlns, and version - are mandatory for ShapeChange to produce a valid .xsd file

../../_images/image62.png

<<Feature Type>>

  • Denotes a feature type according to ISO 19109.

  • For every feature type a global element, a global complex type derived by direct/indirect extension of gml:AbstractFeatureType, and a property type are generated.

  • If no values are specified for the tagged values, ShapeChange uses default values.

../../_images/image63.png

<<CodeList>>

  • Denotes a code list according to ISO 19103

  • The code list can be encoded in two different ways:

    • Either a union of an enumeration and a pattern is generated; the pattern allows the code list to be extended by any text value not predefined in the code list. (See example below)

    • Or a reference to a dictionary and the dictionary itself are generated – <element name=”function” type=”gml:CodeType”/>

../../_images/image64.png
  • Example: Encoding as a union of an enumeration and a pattern:

../../_images/image65.png

ShapeChange Configuration File

The primary mechanism for providing arguments to ShapeChange is an XML-based configuration file. The root element of the configuration file is <ShapeChangeConfiguration>.

Tip

You don’t have to create a config file from scrath. The generic Configuration file will be provided in Moodle as GenericShapeChangeConfigurationFile.xml, but the following elements (highlighted in image) would need to be adapted in the given file before running it.

The following is an explanation of the various elements for your understanding. You need not create them as they are already provided in the configuration file. You only need to adapt the parts highlighted in red.

The file is then divided into four element sections:

  • <input>: contains parameters and other information related to the input model.

  • <dialog>: specifies a user interface dialog for the invocation of ShapeChange. This element is optional.

  • <log>: controls the logging of messages.

  • <targets>: contains information on the targets of the transformation such as an XML Schema document.

../../_images/image66.png

<image>

<input>
  <parameter name="inputModelType" value="EA7"/>
  <parameter name="inputFile" value="………./YourModel.qea"/> --*Please provide the location of your EA Model*
  <parameter name="appSchemaName" value=""/>
  <parameter name="checkingConstraints" value="disabled"/>
  <xi:include href="http://shapechange.net/resources/config/StandardAliases.xml"/>
</input>
  • inputModelType: Format of the application schema. Already Provided

  • inputFile: The path to and the file name of the Input file. Relative to the working Directory or the Absolute Path

  • appSchemaName: Application schema to be processed. When no value is given, all application schemas are being processed.

  • checkingConstraints: OCL constraints are checked.

  • standardAliases.xml: Mapping of application schema stereotypes to well-known standard stereotypes (e.g., FeatureType < > Feature)

<log>

<log>
  <parameter name="reportLevel" value="INFO"/>
  <parameter name="logFile" value="……./log/log_citymodel.xml"/> --*Please provide output location*
</log>
  • reportLevel: The level at which to log messages. Possible values are INFO, WARNING, and ERROR.

  • logFile: The path to and the file name of the XML log file.

<targets>

<targets>
 <TargetXmlSchema class="de.interactive_instruments.ShapeChange.Target.XmlSchema.XmlSchema" mode="enabled">
   <targetParameter name="outputDirectory" value= "………/xsd"/> --*Please provide output location for directory*
   <targetParameter name="defaultEncodingRule" value="iso19136_2007"/>
   <xi:include href="http://shapechange.net/resources/config/StandardRules.xml"/>
   <xi:include href="http://shapechange.net/resources/config/StandardNamespaces-v31.xml"/>
   <xi:include href="http://shapechange.net/resources/config/StandardMapEntries.xml"/>
 </TargetXmlSchema>
 <Target class="de.interactive_instruments.ShapeChange.Target.Codelists.CodelistDictionaries" mode="enabled">
 <targetParameter name="outputDirectory" value= "……/codelists"/> --*Please provide output location for codelists*
 </Target>
</targets>
  • class: A string representing the Java class handling the target.

  • mode: Defines whether the target will be processed (enabled) or not (disabled).

  • outputDirectory: The path where the generated xsd files will be stored.

  • defaultEncodingRule: The identifier of the encoding rule to be applied by ShapeChange. Here: ISO 19136 Annex E.

  • StandardRules.xml: Contains the encoding rule identified above.

  • StandardNamespaces-v31.xml: Contains standard namespace definitions of GML 3.1.1

  • StandardMapEntries.xml: Defines customized mapping from UML classes to target elements, especially from the ISO 191xx and OGC standards to corresponding GML elements (e.g., GM_Surface < > gml:SurfaceType)