Re: XmlQuery and GOB



On Wed, Oct 11, 2000 at 10:18:50AM +0200, Gerhard Dieringer wrote:
> >>> 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
>      ...       ...
> 

Ok with this hierarchy. It is logical.

> 
> 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

This one is to create elements with API calls. Tell me if I am wrong!

> 3.) render to XML (the reverse of the first)
> 4.) render to SQL
> 

The 4th one is a bit different since the rendering should be done by the
provider itself (otherwise you can't generate SQL-like which is specific to a
provider, or maybe is it generic SQL92 that you want to generate here?)

> 
> The groups 1, 3, and 4 are rather simple and consist of one single fu
nction each (right?)

Yep!

> 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");

Wouldn't it be better if the id was derived automatically from the table
name (for example id="TA"+table name) so there is no problem with the ID 
attribute of the DTD (AFAIK for one doc each ID must be unique), and then 
all the tables can be referenced by their name and not id. So the previous
function would be:

xml_query_query_add_target_from_text(XML_QUERY_QUERY(insert),
                                     XML_QUERY_TYPE_TABLE,
                                     "tab_a");
and then:
xml_query_insert_add_dest_from_text(XML_QUERY_INSERT(insert),
                                    "tab_a",
                                    "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);
> }    
> 

Except for the few comments above, I think your idea is the right one
(trying to make only one API for everything is too complicated to write
and for the user to use!)

Thanks for it all!

Vivien

> --------------------------------------------------------
> Comments and suggestions appreciated
> 
> Gerhard
> 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]