MULTEXT - Document MQL 1. MtSgmlQL/Using.

logo

Using MtSgmlQL



Contents



Running MtSgmlQL

The general format of the mtsgmlql command is:

mtsgmlql [options] [queryfile [args] ]

MtSgmlQL can be invoked in three different ways:



Command line arguments and options

MtSgmlQL accepts the following command line arguments and options:

query [args]

The first argument is interpreted as the name of a file containing the query. Following arguments are passed to the script. MtSgmlQL enters non-interactive mode.

Example

mtsgmlql queryfile

-query "inline query"

to give a simple query as a string on the command line. MtSgmlQL enters non-interactive mode.

Example

mtsgmlql -query "every DATE in stdin"

-lang <xx>

-wsd <charset>

-version

Prints the current version of the tool.

-help

Prints a short on-line help.



Interactive mode

When invoked with no arguments, MtSgmlQL enters interactive mode. In this mode, a primary prompt is given before the each query:

Example

Query[1]> 

The number between brackets is incremented at each query. Each query is interpreted and results are output immediately on the standard output.

When a query is to be continued on a new line, a secondary prompt is given to each new line until the completion of the current
query. The number between brackets stays to the same value:

Example

Output can be interrupted by typing ^C.

Interactive mode can be exited by typing ^D or one of the queries bye, exit or quit.



Non-interactive mode

When MtSgmlQL is called from the command line and the -query option is used. If the -query option is not used, the first argument is the name of the file containing the query.

MtSgmlQL variables are assigned values as follows:



Inline Help

MtSgmlQL provides a rudimetary inline-help that may help you to check the syntax of all operators.

This Help is invoked with the operator ?:

Syntaxe:

The first form gives information about help; The second gives information about the <keyword>.

The help about the Help:

Example of help about the replace operator


Error messages

In the current version, handling of errors is still rudimentary in case of syntax error. In the non-interactive mode, the name of the script, the line number are also reported.

The predefined global variable $_status is updated after each query. Its boolean value reflects the status of the query (This is really like the $? or $status bourne-shell or cshell variables).

Error messages are as follows:

Syntax error

Examples:

Query[13]$ foo;

 Bad function name
   foo;
   ^^^
 Operator 'function', 'foo' not such user function!

Query[14]$ select from where

 parse error
   select from where
          ^^^^

Query[15]$ 

Type mistmatch

Example:

Query[21]$ 1 + "un";

 Bad type
   1 + "un";
     ^
 Operator '+', Waits for one <NUMBER> but gets one <CDATA> from operator '"..."'
   1 + "un";
       ^^^^

Query[22]$ if 1 then 2;

 Bad type
   if 1 then 2;
   ^^
 Operator 'if', Waits for one <BOOLEAN> but gets one <NUMBER> from operator 'number'
   if 1 then 2;
      ^

Query[23]$ 

Division by zero

Example:

Query[24]$ global $a = 0;

Query[25]$ 12 / $a;

 Division by zero
   12 / $a;
      ^
 Operator '/', waits a value not equal to zero but gets it from operator 'variable'
   12 / $a;
        ^^

Query[26]$ define plus($a,$b) as $a + $b;

Query[27]$ plus(1,2);
3
Query[28]$ 12 / plus(0,0);

 Division by zero
   12 / plus(0,0);
      ^
 Operator '/', waits a value not equal to zero but gets it from operator 'function'
   12 / plus(0,0);
        ^^^^

Query[29]$ 

Example (from a file "trial.html")

2364$ ./mtsgmlql trial.html
3
mtsgmlql:
 In file "trial.html", line 3:  Division by zero
   12 / plus(0,0);
      ^
 Operator '/', waits a value not equal to zero but gets it from operator 'function'
   12 / plus(0,0);
        ^^^^
2365$ 


I/OErrors


| Top | Next | MtSgmlQL | LPL/CNRS | MULTEXT

Copyright © Centre National de la Recherche Scientifique, 1997.