cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geurt Wisselink" <...@home.nl>
Subject RE: SQL Transformer Bug?
Date Sat, 18 Nov 2006 18:56:32 GMT
Dear Dan,

I ran into the same problem and ended up modifying the transformer.
I returned the modified version to the cocoon development group.

I added two options to work with xml.

The first was the original foreseen sql:xml construct.
Basically it works like this:
<sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0">
<sql:query name="nodeset">
INSERT INTO mytable (nodeset)
VALUES ('<sql:xml><root><record id="1"><name>John 
Smith</name><city>London<city></record></root></sql:xml>');
</sql:query>
</sql:execute-query> 

In this way a string is created with the XML content in side.

The second thing I added was the capability to work with xml variables by
means of the sql:in-xml-parameter.
It works like the standard in-parameter but is tailored to work with XML
content.
This works like:
<sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0">
<sql:in-xml-parameter nr="1"><root><record id="1"><name>John 
Smith</name><city>London<city></record></root></sql:in-xml-parameter>
<sql:query name="nodeset">
INSERT INTO mytable (nodeset)
VALUES (?);
</sql:query>
</sql:execute-query>

The modified SQLTransformer is added as attachment to this mail. 
Just put it src\blocks\databases\java\org\apache\cocoon\transformation, and
rerun build.

This last option is the best for last XML blocks, because the data is
streamed to the database engine, instead of embedding it into a SQL query.

I hope this helps.


Kind regards,

Geurt Wisselink

-----Original Message-----
From: Dan Hertz [mailto:dan@danhertz.com] 
Sent: 18 November 2006 17:10
To: dev@cocoon.apache.org
Subject: SQL Transformer Bug?

I'm hoping someone can help me troubleshoot why I can't insert an xml 
nodeset into my database using the SQL Transformer. All I end up with is 
the text() values concatenated together -- no elements or attribute 
nodes. For example:

<sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0">
<sql:query name="nodeset">
INSERT INTO mytable (nodeset)
VALUES ('<root><record id="1"><name>John 
Smith</name><city>London<city></record></root>');
</sql:query>
</sql:execute-query>

would insert: 1JohnSmithLondon into my database.

If I plug this query into my sql editor, I correctly get:
<root><record id="1"><name>John 
Smith</name><city>London<city></record></root>
inserted into the database.

What am I doing wrong?

Thanks!

Mime
View raw message