next up previous contents
Next: Simple expressions in patterns Up: User-defined Answer Formats Previous: User-defined Answer Formats

Basic definitions

By default, ConceptBase displays answers to queries in the FRAME format (see `A' and `B' below). For many applications, other answer representations are more useful. For example, relational data is more readable in a table structure. Another important example are XML data. If ConceptBase is integrated into a Web-based information system, then answers in HTML format are quite useful. For this reason, answer format definitions are provided.

Answer formats in ConceptBase are based on term substitutions where terms are evaluated against substitution rules defined by the answers to a query. A substitution rule has the form tex2html_wrap_inline4161 with the intended meaning that a substring L in a string is replaced by the substring R. The object of a term substitution is a string in which terms may occur, for example:

this is a string called {a} with a term {b}

Assume the substitution rules:

The derivation of a string with terms proceeds from left to right. First, the term occurence {a} is dealt with. The next term in the string is then {x} which is evaluated to 123. Finally, {b} is substituted and the result string is this is a string called string no. 123 with a term that was subject to substitution.

We denote a single derivation step of a string tex2html_wrap_inline4173 to a string tex2html_wrap_inline4175 by tex2html_wrap_inline4177 . It is defined when there occurs a substring L in tex2html_wrap_inline4173 , i.e. tex2html_wrap_inline4183 and a substitution rule tex2html_wrap_inline4161 and tex2html_wrap_inline4187 . The substrings V and W may be empty. A string S is called ground when no substition rule can be applied. A sequence tex2html_wrap_inline4195 is called a derivation of S. A complete derivation of S ends with a ground string. In our example, the complete derivation is:

tabular1550

An exception to the left-to-right rule are complex terms like {do({y})}. Here, the inner term {y} is first evaluated (e.g. to 20) and then the result {do(20)} is evaluated.

In general, term substitution can result in infinite loops. This looping can be prevented either by restricting the structure of the substitution rule or by terminating the substitution process after a finite number of steps. The end result of a substitution process of a string is called its derivation. In ConceptBase, the substitution rules are guaranteeing termination except for the case of external procedures. The problem with the exception is solved by prohibiting cyclic calls of the same external procedure during the substitution of a call. A cyclic call is a call that has the same function name (e.w. query class) and the same arguments (expressed as parameter substitutions).

In ConceptBase, an answer format is an instance of the new pre-defined class `AnswerFormat'.

Individual AnswerFormat in Class with 
  attribute
     forQuery : QueryClass;
     order : Order;
     orderBy : String;
     head : String;
     pattern : String;
     tail : String
end

The first attribute assigns an answer format to a query class (a query may have at most one answer format). The second and third attribute specify the sorting order of the answer, i.e. one can specify by which field an answer is sorted, and whether the answer objects are sorted `ascending' or `descending' (much like in SQL).

The `head', `pattern', and `tail' arguments are strings that define the substring substitution when the answer is formatted. They contain substrings of type expr that are replaced. The head and tail strings are evaluated once, independent form the answer to the query. Usually, they do not contain expressions but only text. The response to a query is a set of answer objects A1,A2,.... The pattern string is evaluated against each answer object. For each answer object, the derivation of the pattern is put into the answer text. Hence, the complete answer consists of

tabular1559

In the next sections, we will explain more details about answer formats using the following example: An answer object A to a query class QC has by default a `frame' structure

   A in QC with
     cat1
        label11: v11;
        label12: v12
        [...]
     cat2
        label21: v21
     [...]
   end

In case of a complex view definition VC, the values vij can be answer objects themselves, e.g.

   B in VC with
     cat1
        label11: v11;
        label12: v12
        [...]
     cat2
        label21: v21 with
                   cat21
                     label211: v211
                 [...]
                 end
     [...]
   end


next up previous contents
Next: Simple expressions in patterns Up: User-defined Answer Formats Previous: User-defined Answer Formats

ConceptBase Team