Personal tools

6.3. Appendix

Up one level
This appendix contains information about the query language ooXmlQL

ooXmlQL Specification

The following EBNF grammar specifies sound ooXmlQL queries. Remark: A strange behaviour can be observed when using variables where one variable is a prefix of another variable, e.g. $ref and $refAlias. It seems there is a bug in the XQuery processor. Therefore this variable setting should be avoided.

 

ooXmlQuery = query.
query = ‘<query>’ ( queryelements ) ( declareNS )* ‘</query>’
queryelements = ( select )?
            from
            ( declareVar )*
            ( restriction )?
            ( where )?.
select = ‘<select>’ ( ‘*’ | xpath expression+ ) ‘</select>’.
declareNS = ‘<declare name=“’name’”>’ namespace ‘</declare>’.
from = ‘<from as=“’var‘”>’ ( class | setOperation ) ( join )? ‘</from>’.
setOperation = ‘<union>’ ( class | setOperation )+ ‘</union>’ |
               ‘<intersect>’ ( class | setOperation )+ ‘</intersect>’ |
               ‘<except>’ ( class | setOperation )+ ‘</except>’.
class = ‘<class name=“’classname’”/>.
join = ‘<join on=“’relation’” as=“’var’” class=“’class’”>’
            ( restriction )? ( join )?
       ‘</join>.
declareVar = ‘<declare var=“’var’”>’ declaration ‘</declare>’.
where = ‘<where>’ xpath or xquery expression ‘</where>’.
restriction = subquery | and | or | not.
subquery = ‘<query return=“’relationship’”>’
             queryelements
           ‘</query>’.
and = ‘<and>’ restriction+ ‘</and>’
or = ‘<or>’ restriction+ ‘</or>’.
not = ‘<not>’ restriction ‘</not>’.


Variables can be used in

  • where clause
  • declare variable clause
  • select clause

Example ooXmlQL query:

 

<query>
  <select>$sla</select>

  <declare name="ns1">http://it-innovation.soton.ac.uk/2005/grid</declare>
  <declare name="ns2">http://www.w3.org/2005/08/addressing</declare>

  <from as="$sla">
    <class name="Sla"/>
    <join on="provides" as="$res" class="Resource"/>
  </from>

  <declare var="$min">fn:min($sla//cpu)</declare>
  <declare var="$max">fn:max($sla//cpu)</declare>

  <query return="providedBy">
     <from class="Resource" as="$res"/>

     <declare var="$avg">fn:avg($res//cpu)</declare>

     <where>
       $res//ns2:Metadata/ns1:type =
       "uk.ac.soton.ecs.iam.grid.comms.client.RemoteDataService" 
     </where>
  </query>

  <where>$sla//cpu = $min or $sla//cpu = $max</where>
</query>