1 $Id: README,v 1.8 2002-11-01 23:45:28 mike Exp $
3 cql-java -- a free CQL compiler for Java
6 This project provides a set of classes for representing a CQL parse
7 tree (CQLBooleanNode, CQLTermNode, etc.) and a CQLCompiler class which
8 builds a parse tree given a CQL query as input. It also provides
9 compiler back-ends to render out the parse tree as XCQL (the XML
10 representation), as PQF (Yaz-style Prefix Query Format) and as CQL
11 (i.e. decompiling the parse-tree). Oh, and there's a random query
14 CQL is "Common Query Language", a new query language designed under
15 the umbrella of the ZING initiative (Z39.59-International Next
16 Generation). More information at
17 http://zing.z3950.org/cql/index.html
19 XCQL is "XML CQL", a representation of CQL-equivalent queries in XML
20 which is supposed to be easier to parse. More information at
21 http://www.loc.gov/z3950/agency/zing/srwu/xcql.html
22 (not much more, though)
24 But if you didn't know that, why are you even reading this? :-)
32 $ echo "foo and (bar or baz)" | java org.z3950.zing.cql.CQLParser
36 import org.z3950.zing.cql.*
38 // Building a parse-tree by hand
39 CQLNode n1 = new CQLTermNode("dc.author", "=", "kernighan");
40 CQLNode n2 = new CQLTermNode("dc.title", "all", "elements style");
41 CQLNode root = new CQLAndNode(n1, n2);
42 System.out.println(root.toXCQL(3));
44 // Parsing a CQL query
45 CQLParser parser = new CQLParser();
46 CQLNode root = parser.parse("title=dinosaur");
47 System.out.println(root.toXCQL(0));
48 System.out.println(root.toCQL());
49 System.out.println(root.toPQF(qualSet));
50 // ... where `qualSet' specifies CQL-qualfier => Z-attr mapping
56 See the automatically generated class documentation in the "doc"
57 subdirectory. (It's not all there yet, but it's coming.)
63 Mike Taylor <mike@z3950.org>
64 http://www.miketaylor.org.uk
70 This software is open source, but I've not yet decided exactly what
71 licence to use. Be good. Assume I'm going with the GPL (most
72 restrictive) until I say otherwise.
78 Ways of testing the parser and other components include:
80 * Generate a random tree with CQLGenerate, take a copy, and
81 canonicalise it with CQLparser -c. Since the CQLGenerate output is
82 in canonical form anyway, the before-and-after versions should be
91 Adam Dickmeiss's CQL compiler, written in C.
92 Rob Sanderson's CQL compiler, written in Python.
93 All the other free CQL compilers everyone's going to write :-)
99 * Allow CQLGenerate test-harness to take some of its configuration
100 parameters on the command-line as well as or instead of a file.
102 * Some niceties for the cql-decompiling back-end:
103 * don't emit redundant parentheses.
104 * don't put spaces around relations that don't need them.
106 * Write pqn-generating back-end (will need to be driven from a
107 configuation file specifying how to represent the qualifiers,
108 relations, relation modifiers and wildcard characters as z39.50
111 * Consider the utility of yet another back-end that translates a
112 CQLNode tree into a Type-1 query tree using the JZKit data
113 structures. That would be nice so that CQL could become a JZKit
114 query-type; but you could achieve the same effect by generating PQN,
115 and running that through JZKit's existing PQN-to-Type-1 compiler.
117 * Refinements to random query generator:
118 * Generate relation modifiers
120 * Don't always generate qualifier/relation for terms
121 * Better selection of qualifier (configurable?)
122 * Better selection of terms (from a dictionary file?)
123 * Introduce wildcard characters into generated terms
124 * Generate multi-word terms
126 * Write fuller "javadoc" comments.
128 * Write generic test suite.