Re: [gnome-db] sql extension to xslt



On 9/17/07, Paweł Cesar Sanjuan <pawel szklarz cc com pl> wrote:
> Hi.
>
> I prepare a new version of the extension, more similar to gda_reports.
> The new external API:
> // register the extension for libxslt
> void sql_xslt_register(void);
> // create a execution context, with _1_ connection
> SQLExsltExecutionContext
> *gda_xslt_create_context_simple(GdaConnection*cnc,GError **error);
> // set the execution context on a xsltContext
> void sql_xslt_set_execution_context(xsltTransformContextPtr
> tcxt,SQLExsltExecutionContext *exec);
> // clear the structure
> int sqlxslt_finalize_context(SQLExsltExecutionContext *ctx);
>
> I dont create the function
>
> xsltTransformContextPtr *gda_xslt_create_context_simple (GdaConnection
> *cnc, GError **error);
>
> because to create the xsltTransformContextPtr it is needed the xml file,
> or xml from memory, so a made:
>
> SQLExsltExecutionContext
> *gda_xslt_create_context_simple(GdaConnection*cnc,GError **error);
>
> AND
>
> void sql_xslt_set_execution_context(xsltTransformContextPtr
> tcxt,SQLExsltExecutionContext *exec);
>
>
> Libexslt have similar functions to
> void sql_xslt_register(void);
> so, i maybe it is the standart way.

Ok, good! But can you please use the GDA namespace everywhere instead
of SQL, such as
gda_xslt_set_execution_context() instead of sql_xslt_set_execution_context().

>
> I will implement predefined query and multiple connections later.
>
> The new extension give the next extension elements and function:
> functions:
>         "getvalue"
>         "getnodeset"
>         "checkif"
> elements:
>         "section"
>
>
> The 'section' element:
>
> example:
> <sql:section>
>   <!-- no predefined query are registred, so use the sql text inside the
> node -->
>   <sql:query name="user">
>   select * from users
>   where
>   login = ## /*type:gchararray name:"login"*/ AND
>   password = ## /*type:gchararray name:"password"*/
>   </sql:query>
>   <!-- parameters login and password are set on XSLT ($login,...) -->
>   <sql:template>
>   <!-- !!! sql:template allows only
>         ___ONE___ xsl:call_template element (optionally with <xsl:params..
> inside)
>         many xml comments
> -->
>   <!-- another comment-->
>   <xsl:call-template name="userData"/>
>   <!-- test comment on END-->
>   </sql:template>
> </sql:section>
>
> How it works:
> When we find the sql:section node, we
> -- search for the sql:query node
> -- search for the sql:template node
> -- look if the query with @name name is predefined (predefinition not
> implemented), if not find then take the text node inside i create a new
> GdaQuery
> -- Run the query and save the result on a hash, with the name= name
> -- if sql:template exists, then search the xsl:call-template inside
> sql:template and run the template
> -- on exit, clear the query if not predefined, and the results (not
> implemented)
>
> It is not simple to go inside a exstension node, and run the xslt
> procesor. The API from libxslt is not prepared for this. This is why I
> restrict to only 1 xsl:call-template node. Of course, you can use
> parameters.
> By the way: only one extension run xslt nodes inside a extension node:
> 'exsl:document'. But the real code of this extension is inside libxslt
> and not libexslt!!!!
>
> The 'checkif' function:
> a dump version, return true always.
> I need some help here.!!!!!!!
>
> The 'getvalue' function
> String getvalue('query_name','column_name')
> similar to value_to_node. May be the code can be joined
>
> The 'getvalue' function
> NodeSet getvalue('query_name')
> example:
> sql results
> tag      | value      | type
> ---------+------------+-------
> testtag4 | testvalue4 | system
> testtag3 | testvalue3 | system
> testtag2 | testvalue2 | system
> testtag1 | testvalue1 | system
>
> give node set
>       <resultset>
>         <row>
>           <column name="tag">testtag4</column>
>           <column name="value">testvalue4</column>
>           <column name="type">system</column>
>         </row>
>         <row>
>           <column name="tag">testtag3</column>
>           <column name="value">testvalue3</column>
>           <column name="type">system</column>
>         </row>
>         <row>
>           <column name="tag">testtag2</column>
>           <column name="value">testvalue2</column>
>           <column name="type">system</column>
>         </row>
>         <row>
>           <column name="tag">testtag1</column>
>           <column name="value">testvalue1</column>
>           <column name="type">system</column>
>         </row>
>       </resultset>
>
>

As I said I'm no XSLT expert, so if it's waht you think is best, then
it's fine with me!

> The code is on
> http://ambargroup.pl/sqlxslt/libsqlxslt.tar.bz2
>
> I have some problem with the server, if cant download send me a mail and
> I will send the code to you.

Yes, can you send it to me privately, because I can't get it?

Thanks for all,

Vivien


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