mulgara - semantic store

skip navigation

SHOW SITE NAV
fixed
fluid
straight

The <query> Tag

The <query> tag is an XSL extension that enables you to issue iTQLTM commands from within an XSL stylesheet. For example:

<query>
<!CDATA[[
select $person from <rmi://mysite.com/server1#people>
where $person <http://foo#hasName> 'James Gosling';
]]>
</query>

 

The results, in XML format, are normally transformed into something more suitable for the client or into a presentation format like HTML or PDF. Other Descriptors make calls on a Descriptor to perform a task without needing to know how that task is performed. For example, to return the title of a document in between two <title> tags.

 

Most commands require parameters, such as the model, to make them reusable across Mulgara instances and models.

The model parameter is inserted in several ways, as outlined in the XSL specification. However, because the command is contained within a CDATA segment, breaking out of it makes the command difficult for people to read. For example:

<query>
<!CDATA[[
select $person from <]]><xsl:variable select="$model"/>
<!CDATA[[> where $person <http://foo#hasName> 'James Gosling';
]]>
</query>

 

The <query> tag has a workaround to avoid this. If any string in the CDATA section is surrounded by @@ symbols, then the string is replaced with the value of an attribute of the same from within the <query> tag. This is shown in the example below.

<query model="rmi://mysite.com/server1#people">
<!CDATA[[
select $person from <@@model@@> where $person <http://foo#hasName> 'James Gosling';
]]>
</query>

 

When the Descriptor executes, it substitutes rmi://mysite.com/server1#people for @@model@@ before passing the command to Mulgara.

By specifying the parameter as a Descriptor parameter, the value can be passed in by the client. For example:

<query model="{$model}">
<!CDATA[[
select $person from <@@model@@> where $person <http://foo#hasName> 'James Gosling';
]]>
</query>

If the Descriptor is created with a model parameter defined as a string, the query is now portable across models.

These types of substitutions are not limited to models. Any string can be substituted.

Valid XHTML 1.0 TransitionalValid CSS 3.0!