[ query icon ]

Queries

One important requirement of some transformation applications is the ability to select some part of the XML documents to be further transformed. The query abstract transformation covers this goal.

It takes as input the source to be queried and the query to be processed against the input. Its output will be the result.

XML declaration

The apply-query element introduces the use of a query in a process body. Its structure is the following:

<apply-query type="type" ref="name" id="id" in="channel"> {<with-param>}* </apply-query>

Built-in queries

In order to test this interface we defined a very simple query language that only allows the expression of two elements: query which contains a set of select elements. The select elements have a match attribute containing an XPath [clark1999b] expression. The evaluation of the query will return all the subtrees of the input stream that match one of the select clauses. The conjunction can be implemented by composing two such queries. This is a very light query language which does not transform order or provide complex operations but it is embedded in a rich environment which can provide this.

For instance, the following query asks for all the references involving either Troncy or Brunet as author (in any position).

<query name="troncybrunet" type="tmq" root="bibliography"> <select match="bibliography/reference[authors/p/@last='Troncy']"/> <select match="bibliography/reference[authors/p/@last='Brunet']"/> </query> The root attribute specifies that the result is returned within a bibliography element.

This simple query language has been implemented by transforming the query element into an XSLT stylesheet that is processed against the input and returns the result

References to contributed extensions can be found here

Manipulation API

Extension API

Next chapter: Rule sets


Feel free to comment to Jérôme:Euzenat#inrialpes:fr, $Id: queries.html,v 1.7 2005-10-25 13:34:00 euzenat Exp $