The DTD is represented as follows:
An element and its attributes are
shown in the same window. The attributes for the element are shown slightly
indented. If an element has sub elements, there is a Body
button corresponding to it, which presents its sub elements in a different
window. A check box for an element/attribute is used to determine if the
element/attribute is to be displayed in the output of the query. A textbox
is provided only if a constraint can be specified for the element/attribute,
e.g., an EMPTY element cannot have a constraint specified on the element.
4. For starters, let us just select
the checkbox corresponding to the Memo element on the "Root Element Window".
This implies that we wish to query the Memo element for all the documents
in the database.
5. Now click Apply.
The "Root Element Window" disappears. The yellow box on the canvas carries
the name of the DTD you just associated the box with. As seen, the
name is appended with a unique number to identify a node distinctly in
case of more than one node being associated with the same DTD (in case
of a join condition).
6. Click the Generate
button. This generates the query in Poet OQL format and if you are using
QT4XML in client- server mode, you will see the results in a new frame.
You will have to click the Exit button
on the new frame before we proceed. If QT4XML is in the standalone mode,
then the query can be seen as on the console or in the file qry.oql in
your QT4XML/Query directory.
This was a simple query with no constraints.
To add constraints, click Update
and select the node on the canvas. (To understand the DTD structure, you
can look up Memo.dtd from QT4XML/Files directory.) When you click on the
Body
button, the body/contents of the element Memo are shown in a different
window. From the drop down box (under OPERATOR label), a relational operator
can be selected. Let us select "==" for Recipient and in the text box for
From, type in "John Miller" with the double quotes (Any string that has
spaces in it has to be enclosed within double quotes). Again click apply
on both windows and then click
Generate.
This is a query to view memos, where the sender is John Miller.
The QT4XML grammar is available
at http://cobweb.cs.uga.edu/~sonali/papers/qt4xml.ps
A subsection of the grammar is currently implemented, some of it being
seen in the following example:
Use of wildcard characters and regular expression
operators:
Wildcard character: ^
Regular expression operators: * (currently
only supported as ^*), &
(AND )
For OR conditions, : is used.
Let us look at a sample query, to see how these operators are used:
Query: Select the memos where
Other features
on the main canvas:
Link:
QT4XML can be used to specify join
conditions graphically, but does not generate code for the same currently.
When more than one node is drawn on the canvas using the Query button,
they can be linked together using the link button. Click on Link and then
click on the 2 nodes to be linked. Conditions can be specified for this
link, by clicking Update and then clicking on link.
Create_classes: This is used to create java classes corresponding to the DTD under consideration. These classes can be seen in the QT4XML/JavaFiles directory. The classes needed to use these generated classes can be obtained from the developer of QT4XML. These are used to upload data into Poet database.
Other features
on root element windows/element windows:
Link, Done,
UnLink, AND/OR connector:
The Link button is used to link
elements for AND or OR conditions. This is done as follows. Click the Link
button. Click in the red rectangle on the right of element say A and then
click similarly for element B, C... Click Done when you are done. Now,
to specify if this link is and AND or OR, use the toggle button named as
AND/OR connector. All conditions linked together are ANDed or ORed as specified
by the connector label and remaining are ORed if AND connector is on and
vice versa. To delete a link, click on UnLink and choose the Link to be
deleted.
Duplicate:
Duplicates an element or attribute.
Used to specify complex conditions. To use, click on duplicate and click
in the text box of the element/attribute to be duplicated.
Get:
The get button can be used to associate
a different query with the node at any time. Remember to click apply to
save the changes.
Cancel:
Cancel the conditions assigned.