Re: XmlQuery and GOB
- From: "Gerhard Dieringer" <DieringG eba-haus de>
- To: <malerba gears linuxave net>
- Cc: "<" <gnome-db-list gnome org>
- Subject: Re: XmlQuery and GOB
- Date: Wed, 11 Oct 2000 10:18:50 +0200
>>> Vivien Malerba <malerba gears linuxave net> 09.10.2000 18.14 Uhr >>>
> ...
> However, from what I can understand from the .gob files, I agree with what
> you propose. If you have some time and want t go further with your ideas,
> no problem with me!
> ...
Hi Vivien,
I startet implementing XML-Query (with Insert, because it's less complex than select)
Object hierarchy:
Xml:Query:Item (abstract base class, derived from GtkObject)
|
+-- Xml:Query:Target
|
+-- Xml:Query:View
|
+-- Xml:Query:Table
|
+-- Xml:Query:Value
|
+-- Xml:Query:Field
|
+-- Xml:Query:Const
|
+-- Xml:Query:List (may get changed to an abstract base class)
|
+-- Xml:Query:Query (abstract base class)
| |
| +-- Xml:Query:Select
| |
| +-- Xml:Query:Insert
... ...
The API has four groups of methods:
1.) create from DOM-tree (DOM-tree is created by libxml from XML doc)
2.) create from text
3.) render to XML (the reverse of the first)
4.) render to SQL
The groups 1, 3, and 4 are rather simple and consist of one single function each (right?)
1.) XmlQueryItem *xml_query_create_from_node(xmlNode *node)
3.) gchar *xml_query_to_xml(XmlQueryItem *item)
4.) gchar *xml_query_to_sql(XmlQueryItem *item)
group 2 is rather complex and allows the construction of a query step by step
example:
SQL:
INSERT INTO tab_a (ival, sval) VALUES (1,'abc')
XML:
<query>
<insert>
<target>
<table id="t1" name="tab_a"/>
</target>
<dest>
<field source="t1" name="ival"/>
<field source="t1" name="sval"/>
</dest>
<valuelist>
<value>
<const value="1" type="int"/>
</value>
<value>
<const value="abc" type="char"/>
</value>
</valuelist>
</insert>
</query>
This query is constructed by the following sequence:
{
XmlQueryItem *insert;
insert = xml_query_insert_new();
xml_query_query_add_target_from_text(XML_QUERY_QUERY(insert),
XML_QUERY_TYPE_TABLE,
"t1",
"tab_a");
xml_query_insert_add_dest_from_text(XML_QUERY_INSERT(insert),
"t1",
"a");
xml_query_insert_add_dest_from_text(XML_QUERY_INSERT(insert),
"t1",
"b");
xml_query_query_add_const_from_text(XML_QUERY_QUERY(insert),
"1",
"int",
FALSE);
xml_query_query_add_const_from_text(XML_QUERY_QUERY(insert),
"abc",
"char",
FALSE);
}
--------------------------------------------------------
Comments and suggestions appreciated
Gerhard
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]