You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Rob Frohwein <ro...@robf.nl> on 2007/06/16 18:58:29 UTC

Cocoon database access strategy

Hi,
For some project I need to make rather deeply nested database queries.
I was looking for the best stategy (I am new to cocoon)

----------------------------------------------
1 Doing all nested queries in one xsp or xml page.
But this will be difficult to maintain and test.
----------------------------------------------
2 extending queries in one pipeline
In this strategy a resultset is extended by following steps in the pipeline.

sitemap.xmap:
<map:pipeline>
	<map:match pattern="start">
	<map:generate type="file" src="query1.xml"/>
			
        	<map:transform type="sql">
	...

	<map:transform type="xslt" src="query2.xsl"/>
        	
	<map:transform type="sql">
	...

	</map:match>
</map:pipeline>

query1.xml could do a first level query.
query2.xsl could do some processing and at some point in the tree
do a new query and append the resultset there.(sqltaglib can be used in 
xslt)

But this seems not to work, because the first resultset creates
elements like <sql:somename> the second sqltransform step will be 
confused by these tags.
I could rename all <sql:somename> tags after the first sqltransform 
step, but that is a bit clumsy.

So this does not work.
I also understood from the documentation that it's not possible
to use more then one xsp in a pipeline, so this approach will
also not be possible with esql?

----------------------------------------------
3 Call pipeline entries from an xsp/xml sql query loop:

In this case I would like something like:
query1.xsp:
<customer>
	<esql:connection>
	<esql:pool>fwstat</esql:pool>

	<esql:execute-query >
		<esql:query>
			select * from customers
		</esql:query>
		<esql:results>
			<esql:row-results>
				Call query2.xsp(
					<esql:get-string column="id"/>
					<esql:get-string column="name"/>
					)
			</esql:row-results>
		</esql:results>
	</esql:execute-query>
	</esql:connection>
</customer>
query2.xsp would do a new query with the supplied parameters.
query2.xsp could ofcourse do other queries.

But I could not find constructs like this.
----------------------------------------------

What is the best approach to separate the nested queries?

Thanks.
Rob

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon database access strategy

Posted by so...@apache.org.
On 6/16/07, Rob Frohwein <ro...@robf.nl> wrote:
> I also understood from the documentation that it's not possible
> to use more then one xsp in a pipeline
> Rob

That depends on your definition of pipeline.
1. The map:pipeline element decides caching and defines error
handling.  More than one XSP can be in a map:pipeline.
2. A map:match element defines an input->output.  XSP requires the
map:generate element because the map:aggregate element does not
understand the type property.  A map:match can only have one XSP.
3. A pipeline can be defined as all processing needed to create one
output.  The map:aggregate can include multiple map:match inputs each
using one XSP.  I have a pipeline that uses two simple XSPs: one for
login information and one for POST information.  (The latter allows
forms to be used with just XSL and XMAP elements, no JS Flow
required.)

solprovider

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon database access strategy

Posted by warrell harries <wa...@googlemail.com>.
Hi,

Does the database you are using support stored procedures (even MySql now
does)? If so, write the complex SQL as a strored procedure and then execute
the stored procedure from the SQLTransformer, possibly using the ancestor
construct that the SQLTransformer has specifically to support nested
Queries.

Personally, I don't see a problem with doing some XSL transformation after
one query before doing another based on the output DOM; this is what XML
pipelines are all about. Perhaps you are not very familiar with XSL. Invest
some time and you will be rewarded!

XSL and Database Actions are deprecated so I would recommend the pipeline
approach as you will end up with a more maintainable and extensible solution
because you will seperate the concerns.

Regards,

Warrell

On 16/06/07, Rob Frohwein <ro...@robf.nl> wrote:
>
>
> Hi,
> For some project I need to make rather deeply nested database queries.
> I was looking for the best stategy (I am new to cocoon)
>
> ----------------------------------------------
> 1 Doing all nested queries in one xsp or xml page.
> But this will be difficult to maintain and test.
> ----------------------------------------------
> 2 extending queries in one pipeline
> In this strategy a resultset is extended by following steps in the
> pipeline.
>
> sitemap.xmap:
> <map:pipeline>
>         <map:match pattern="start">
>         <map:generate type="file" src="query1.xml"/>
>
>                 <map:transform type="sql">
>         ...
>
>         <map:transform type="xslt" src="query2.xsl"/>
>
>         <map:transform type="sql">
>         ...
>
>         </map:match>
> </map:pipeline>
>
> query1.xml could do a first level query.
> query2.xsl could do some processing and at some point in the tree
> do a new query and append the resultset there.(sqltaglib can be used in
> xslt)
>
> But this seems not to work, because the first resultset creates
> elements like <sql:somename> the second sqltransform step will be
> confused by these tags.
> I could rename all <sql:somename> tags after the first sqltransform
> step, but that is a bit clumsy.
>
> So this does not work.
> I also understood from the documentation that it's not possible
> to use more then one xsp in a pipeline, so this approach will
> also not be possible with esql?
>
> ----------------------------------------------
> 3 Call pipeline entries from an xsp/xml sql query loop:
>
> In this case I would like something like:
> query1.xsp:
> <customer>
>         <esql:connection>
>         <esql:pool>fwstat</esql:pool>
>
>         <esql:execute-query >
>                 <esql:query>
>                         select * from customers
>                 </esql:query>
>                 <esql:results>
>                         <esql:row-results>
>                                 Call query2.xsp(
>                                         <esql:get-string column="id"/>
>                                         <esql:get-string column="name"/>
>                                         )
>                         </esql:row-results>
>                 </esql:results>
>         </esql:execute-query>
>         </esql:connection>
> </customer>
> query2.xsp would do a new query with the supplied parameters.
> query2.xsp could ofcourse do other queries.
>
> But I could not find constructs like this.
> ----------------------------------------------
>
> What is the best approach to separate the nested queries?
>
> Thanks.
> Rob
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>