Template-Axiom-Query (TAQ)

Resources

A resource is a binding to an external data supplier and/or consumer. Data is exchanged using Axioms. Resources should be declared at the beginning of an TAQ program to make them stand out.

Basic Format

A basic resource declaration starts with the keyword resource followed by the name of the resource and then one or two role qualifiers, enclosed in braces. Role qualifiers define the resource as a data source or a data consumer, or both (a bi-directional resource).

dictionary.taq has a dual role resource reads words from a dictionary file and writes the solution to the console. This is the "lexicon" resource declared to provide an axiom source named "dictionary" with term names "word" and "definition", a nd consume the output of a template named "in_words"

resource lexicon
{
axiom dictionary(word, definition)
template in_words
}

The "axiom" role qualifier has the format of an axiom header and indicates the resource is a data source . The "template" role qualifier indicates the resource is also a data consumer. It names the "in_words" template as the data source to which the resource will connect.

The lexicon resource reads a text file named "i-words.taq" where each line contains a word beginning with the letter 'i' and a definition. Each line is translated to "dictionary" axiom. The "query_in_words" query, by means of the "in_words" template generates a solution axiom for each word beginning with "in" which the lexicon resource translates to a line of text written to the console.

System Format

Each resource provider has a system name used to select it out of all available providers. The resource name of the basic format doubles as the system name. The system format extends the basic format by adding a system name and optional properties. The system name appears in quotes following the resource name and separated by a ':' colon. The properties, if included, are a comma-delimited set of key=value pairs enclosed in parentheses.

Here is the first line of a system format declaration appearing in the forthcoming example:

resource german_colors : "xstream" (filename="DE")

This declares a resource named "german_colors" that refers to a file system provider by the name of "xstream" and defines a "filename" property with value "DE". The file system provider is is both data source and consumer and uses the Thoughtworks xstream library to serialize objects to XML and back again.

The system name allows for the following cases:

  • The system name is not meaningful as a resource name
  • The system name does not comply with naming conventions
  • More than one resource is declared using the same provider
  • Properties need to be specified

Scopes

Resources can only be declared in the global scope. This means every resource name must be unique and can be referenced using only a 1-part name. However, a role qualifier can be assigned to any scope by using a 2-part name. Such a resource member can participate in a program like any other scope artifact. In particular

  • A data-source can act like a context list
  • A data-consumer can specify a source scope