| Model Query Language |
| Authors: |
Patrick Houbaux (Eurostep) Tero Hemio (Eurostep) Yoshinobu Adachi (SECOM) |
| Reference: |
SABLE-PMQL |
| Status: |
Initial proposal (25rd
June, 2003) - 1st, 2nd July, 2003: adding the specifications - last update: 3rd July, 2003 |
| Reviewers: | |
| Legend: |
Introduction
This document describes the functionality and the specifications of the XML based Query Language that will be used in SABLE for querying the data on model servers.
In the context of model servers, several "Query Language" have been created so far but have not been compared and unified.In this document we will first enumerate and describe the different existing "Query Languages" in terms of functionality and possibilities, then in the second part we will define the functional requirements of the SABLE Model Query Language. In the third part we will describe the specifications of the SABLE Model Query Language.
Existing Query Languages
PMQL from SECOM/VTT in IMSvr
<TBC>
PMQL from Eurostep in EMS
<TBC>
Query Language in EXPRESS-X (10303-14)
<TBC>
Functional Requirements
What we want to get?
- Partial Model
- References to instances (Model Server IDs) in one model
What we want to do?
- select instances based on a criteria
Are the following functionality required or not?
- insert new data in the model <not supported by the query language>
- update existing data in the model <not supported by the query language>
How?
- selection criteria based on:
- entity type
- attribute value
- ownership
- creation/modification date
- version history
what about the next one?
- combination of attribute Values: selection based on the result of a calculation of different attribute values.
Examples of Use Cases
Specifications of the SABLE XML based Query Language
SABLE Query Language Keywords
SABLE Query Language structure
<sable_ql ...>
<description>...</description>
<property ...>
<property ...>
<query> ... </query>
<response> ...</response>
</sable_ql>Root Element
Description of the query (Optional)
Property definitions (Optional)
Query definition
Content definition of the response of the query (Optional)SABLE Query Language Clause
The <sable_ql> element is the XML root element of the query language.
The target namespace is http://www.blis-project.org/~sable/PMQLSchema.
The location of the schema is:
http://www.blis-project.org/~sable/subprojects/modelservers/querylanguage/sable_ql.xsd
diagram namespace http://www.blis-project.org/~sable/PMQLSchema children pmqls:description pmqls:property pmqls:query pmqls:response annotation
documentation Root Element for defining the query and response form.source <xs:element name="sable_ql"> <xs:annotation> <xs:documentation>Root Element for defining the query and response form.</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element ref="pmqls:description" minOccurs="0"/> <xs:element ref="pmqls:property" minOccurs="0" maxOccurs="unbounded"/> <xs:element ref="pmqls:query"/> <xs:element ref="pmqls:response" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element>
The <description> element allows to provide a human readable text explaining the query and result that should be returned.
diagram namespace http://www.blis-project.org/~sable/PMQLSchema type xs:string used by
element sable_ql annotation
documentation Human readable text explaining the purpose of the query.source <xs:element name="description" type="xs:string"> <xs:annotation> <xs:documentation>Human readable text explaining the purpose of the query.</xs:documentation> </xs:annotation> </xs:element>
The <query> clause define the body of the query. It contains at leat one <select> clause child element.
diagram namespace http://www.blis-project.org/~sable/PMQLSchema children pmqls:select used by
element sable_ql annotation
documentation Defines the body of the querysource <xs:element name="query"> <xs:annotation> <xs:documentation>Defines the body of the query</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence maxOccurs="unbounded"> <xs:element ref="pmqls:select"/> </xs:sequence> </xs:complexType> </xs:element>
The <select> clause element allows to specify the entity and the associated criteria for which the selection will be made. It contains a sequence of one <entity> element, one optional <where> clause element and one optional <except> clause element.
diagram namespace http://www.blis-project.org/~sable/PMQLSchema children pmqls:entity pmqls:where pmqls:except used by
element query annotation
documentation SELECT clause of the querysource <xs:element name="select"> <xs:annotation> <xs:documentation>SELECT clause of the query</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element ref="pmqls:entity"/> <xs:element ref="pmqls:where" minOccurs="0"/> <xs:element ref="pmqls:except" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element>example#1: The following example shows the use of the <select> clause. This example returns all the references to all instances of IfcWall in the a model.
<sable_ql xmlns="http://www.blis-project.org/~sable/PMQLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blis-project.org/~sable/PMQLSchema
http://www.blis-project.org/~sable/subprojects/modelservers/querylanguage/sable_ql.xsd">
<description>Returns references to all instances of IfcWall</description>
<query>
<select>
<entity name="IfcWall"/>
</select>
</query>
</sable_ql>
The <where> clause element allows to define the criteria on which the selection will be made. It contains a choice of one of the comparison operators or the logical operators.
diagram namespace http://www.blis-project.org/~sable/PMQLSchema children pmqls:lt pmqls:gt pmqls:eq pmqls:neq pmqls:gteq pmqls:lteq pmqls:between pmqls:notBetween pmqls:typeOf pmqls:notTypeOf pmqls:isNull pmqls:isNotNull pmqls:OneOf pmqls:notOneOf pmqls:and pmqls:or pmqls:not pmqls:xor used by
element select annotation
documentation WHERE clause for the SELECT clausesource <xs:element name="where"> <xs:annotation> <xs:documentation>WHERE clause for the SELECT clause</xs:documentation> </xs:annotation> <xs:complexType> <xs:choice> <xs:element ref="pmqls:lt"/> <xs:element ref="pmqls:gt"/> <xs:element ref="pmqls:eq"/> <xs:element ref="pmqls:neq"/> <xs:element ref="pmqls:gteq"/> <xs:element ref="pmqls:lteq"/> <xs:element ref="pmqls:between"/> <xs:element ref="pmqls:notBetween"/> <xs:element ref="pmqls:typeOf"/> <xs:element ref="pmqls:notTypeOf"/> <xs:element ref="pmqls:isNull"/> <xs:element ref="pmqls:isNotNull"/> <xs:element ref="pmqls:OneOf"/> <xs:element ref="pmqls:notOneOf"/> <xs:element ref="pmqls:and"/> <xs:element ref="pmqls:or"/> <xs:element ref="pmqls:not"/> <xs:element ref="pmqls:xor"/> </xs:choice> </xs:complexType> </xs:element>Example#2: The following example shows the use of the <where> clause. This example returns all the references to the instances of IfcWall for which the Label attribute is set to "IfcWall#1000".
<sable_ql xmlns="http://www.blis-project.org/~sable/PMQLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blis-project.org/~sable/PMQLSchema
http://www.blis-project.org/~sable/subprojects/modelservers/querylanguage/sable_ql.xsd">
<description>Returns references to all instances of IfcWall that have the attribute 'Label' set to IfcWall#1000</description>
<query>
<select>
<entity name="IfcWall"/>
<where>
<eq>
<attribute name="Label"/>
<string value="IfcWall#1000"/>
</eq>
</where>
</select>
</query>
</sable_ql>
The <except> clause element allows to remove from the result of the query some particular instances of subclasses of the selected entity in the <select> clause. It contains at least one <entity> element.
diagram namespace http://www.blis-project.org/~sable/PMQLSchema children pmqls:entity used by
element select annotation
documentation EXCEPT clause for the SELECT clausesource <xs:element name="except"> <xs:annotation> <xs:documentation>EXCEPT clause for the SELECT clause</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence maxOccurs="unbounded"> <xs:element ref="pmqls:entity"/> </xs:sequence> </xs:complexType> </xs:element>Example#3: The following example shows the use of the <except> clause. This example returns all the references to the instances of IfcProduct but not IfcBeam and IfcColumn.
<sable_ql xmlns="http://www.blis-project.org/~sable/PMQLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blis-project.org/~sable/PMQLSchema
http://www.blis-project.org/~sable/subprojects/modelservers/querylanguage/sable_ql.xsd">
<description>Returns references to all instances of IfcProduct except IfcBeam and IfcColumn</description>
<query>
<select>
<entity name="IfcProduct"/>
<except>
<entity name="IfcBeam"/>
<entity name="IfcColumn"/>
</except>
</select>
</query>
</sable_ql>
The <response> clause element allows to specify the structure of the returned partial model. If this element does not exist in the <sable_ql> element, then all queries will only return references to instances. If this element exist in the <sable_ql> element, the <content> child element will specify the structure of the returned partial model.
diagram namespace http://www.blis-project.org/~sable/PMQLSchema children pmqls:content used by
element sable_ql annotation
documentation Defines the structure of the response to the querysource <xs:element name="response"> <xs:annotation> <xs:documentation>Defines the structure of the response to the query </xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence maxOccurs="unbounded"> <xs:element ref="pmqls:content"/> </xs:sequence> </xs:complexType> </xs:element>Example#4: The following example shows the use of the <response> clause. This example returns the partial model containing all instances of IfcWall for which the Label attribute is set to "IfcWall#1000". Instances refered from these IfcWall instances are not contained in the response, they are just references in the attributes of these IfcWall instances.
<sable_ql xmlns="http://www.blis-project.org/~sable/PMQLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blis-project.org/~sable/PMQLSchema
http://www.blis-project.org/~sable/subprojects/modelservers/querylanguage/sable_ql.xsd">
<description>Returns partial model of instances of IfcWall for which the "Label" attribute is set to 'IfcWall#1000'</description>
<query>
<select>
<entity name="IfcWall"/>
<where>
<eq>
<attribute name="Label"/>
<string value="IfcWall#1000"/>
</eq>
</where>
</select>
</query>
<response>
<content>
<entity name="IfcWall"/>
</content>
</response>
</sable_ql>
The <content> clause element allows to specify the content of the returned partial model. It contains one <entity> child element and optionally some <path> elements allowing to define precisely the path for each attribute of the entitity that needs to be part of the partial model. If there is no <path> child elements, then the partial model contains only instances of <entity> and the attributes that refer to other instances are set as external references. See Example#4 for an example of usage.
diagram namespace http://www.blis-project.org/~sable/PMQLSchema children pmqls:entity pmqls:path used by
elements include response annotation
documentation Defines if the values of the attributes are to be included in the response as references or as embedded instancessource <xs:element name="content"> <xs:annotation> <xs:documentation>Defines if the values of the attributes are to be included in the response as
references or as embedded instances</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element ref="pmqls:entity"/> <xs:element ref="pmqls:path" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element>
The <path> clause element allows to specify the attribute path that should be included or excluded in or from the content of the returned partial model. It contains the <attribute> element and an <include> or <exclude> element depending if the instance refered by this <attribute> as to be included or excluded from the partial model.
diagram namespace http://www.blis-project.org/~sable/PMQLSchema children pmqls:attribute pmqls:include pmqls:exclude used by
element content annotation
documentation Defines if the value of the specified attribute is to be included in to the response as reference or as a embedded instancesource <xs:element name="path"> <xs:annotation> <xs:documentation>Defines if the value of the specified attribute is to be included in
to the response as reference or as a embedded instance</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element ref="pmqls:attribute"/> <xs:choice> <xs:element ref="pmqls:include"/> <xs:element ref="pmqls:exclude"/> </xs:choice> </xs:sequence> </xs:complexType> </xs:element>Example#5: The following example shows the usage of the <path> clause. This example returns a partial model containing all instances of IfcWall and only the instances of geometry information directly referenced from those. Values of other attributes refering to other instances are returned as references.
<sable_ql xmlns="http://www.blis-project.org/~sable/PMQLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blis-project.org/~sable/PMQLSchema
http://www.blis-project.org/~sable/subprojects/modelservers/querylanguage/sable_ql.xsd">
<description>Returns partial model containing all instances of IfcWall and only the instances of geometry information directly referenced from those. Values of other attributes refering to other instances are returned as references.</description>
<query>
<select>
<entity name="IfcWall"/>
</select>
</query>
<response>
<content>
<entity name="IfcWall"/>
<path>
<attribute name="Representation"/>
<include recursion_depth="1"/>
</path>
</content>
</response>
</sable_ql>
The <include> clause element allows to specify that the current attribute path is included in the content of the returned partial model. This element can optionally contain the <content> element to defined the path recursively.
This element has an optional attribute called "recursion_depth" that, if specified, indicate the level of references included with this attribute. If the value of this attribute is "1", then just the first level of references from this attribute is included in the partial model. If the value is "unbounded", the full partial model from this attribute is returned.The example#5 shows the usage of the <include> clause.
diagram namespace http://www.blis-project.org/~sable/PMQLSchema children pmqls:content used by
element path attributes
Name Type Use Default Fixed Annotation recursion_depth xs:string optional 1 annotation
documentation Definition of the path to be included in the partial model. The recusion depth indicated the number of level to be included.source <xs:element name="include"> <xs:annotation> <xs:documentation>Definition of the path to be included in the partial model.
The recusion depth indicated the number of level to be included.</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence minOccurs="0"> <xs:element ref="pmqls:content"/> </xs:sequence> <xs:attribute name="recursion_depth" type="xs:string" use="optional" default="1"/> </xs:complexType> </xs:element>
The <exclude> clause element allows to specify that the current attribute path is excluded from the content of the returned partial model.
diagram namespace http://www.blis-project.org/~sable/PMQLSchema used by
element path annotation
documentation Definition of the path to be excluded in the partial modelsource <xs:element name="exclude"> <xs:annotation> <xs:documentation>Definition of the path to be excluded in the partial model</xs:documentation> </xs:annotation> <xs:complexType/> </xs:element>
The <property> clause element allows to set property or set of properties from an external file for the query. A property can be parametrized.
Properties are immutable: whoever sets a property first freezes it for the rest of the query; they are most definately not variable.There are 3 ways to set properties:
* By supplying both the name and value attribute.
* By supplying the uri and if needed the parameters attribute. The uri must be pointing to an external file that contains some property definition in the same format as if they were in the current SABLE query or pointing to an internal property.
* By supplying both the name and the list of comma separated parameters. In this case properties can be seen asA property might contain references to other properties. These references are resolved at the time these properties are set. This also holds for properties loaded from a property file.
diagram namespace http://www.blis-project.org/~sable/PMQLSchema children pmqls:attribute pmqls:metadata pmqls:property used by
elements between divide eq gt gteq isNotNull isNull lt lteq multiply neq notBetween notOneOf notTypeOf OneOf property sable_ql substract sum typeOf attributes
Name Type Use Default Fixed Annotation name xs:string optional uri xs:anyURI optional parameters xs:string optional value xs:string optional annotation
documentation Defines an attribute path as a stored property to be used in the query. Properties might be defined outside the current SABLE query file.source <xs:element name="property"> <xs:annotation> <xs:documentation>Defines an attribute path as a stored property to be used in the query.
Properties might be defined outside the current SABLE query file.</xs:documentation> </xs:annotation> <xs:complexType> <xs:choice minOccurs="0"> <xs:element ref="pmqls:attribute"/> <xs:element ref="pmqls:metadata"/> <xs:element ref="pmqls:property"/> </xs:choice> <xs:attribute name="name" type="xs:string" use="optional"/> <xs:attribute name="uri" type="xs:anyURI" use="optional"/> <xs:attribute name="parameters" type="xs:string" use="optional"/> <xs:attribute name="value" type="xs:string" use="optional"/> </xs:complexType> </xs:element>Example#6: Setting a property value and using its value.
<sable_ql xmlns="http://www.blis-project.org/~sable/PMQLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blis-project.org/~sable/PMQLSchema
http://www.blis-project.org/~sable/subprojects/modelservers/querylanguage/sable_ql.xsd">
<description>Returns references to all instances of IfcWall for which the attribute 'Label' is set to the value of the property 'labelName'</description>
<!-- definition of a property value to be used in the query -->
<property name="labelName" value="IfcWall#100"/>
<query>