You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by heli <he...@gmx.at> on 2002/02/11 07:35:31 UTC

database

hi all,

has someone an example howto get an image out of a database (blob)
and display it in html?

I worked finally out how to setup a request to a database.
In the docu (about actions) there is an example but without the
configuration in the sitemap.
Probably somebody can add it to the docu (better by esql or request).

Is there a simplier solution?

in the sitemap.xmap:
    <map:match pattern="heli/test">
     <map:generate type="serverpages" src="docs/samples/heli/test.xsp"/>
     <map:transform type="sql">
       <map:parameter name="use-connection" value="pgsql"/>
     </map:transform>
     <map:transform src="docs/samples/heli/test.xsl"/>
     <map:serialize/>
    </map:match>


-------------test.xsp------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>

<xsp:page
           language="java"
           xmlns:xsp="http://apache.org/xsp"
		  xmlns:sql="http://apache.org/cocoon/SQL/2.0"
           xmlns:xsp-request="http://apache.org/xsp/request/2.0">
<html>
	<b>Request method:</b> <xsp-request:get-method/>
	<br/>
	<b>Fruit requested:</b> <xsp-request:get-parameter name="id"/>

<execute-query xmlns="http://apache.org/cocoon/SQL/2.0">
<query>
   SELECT * FROM test
   WHERE row2 like '%<xsp-request:get-parameter name="id"/>%'
</query>
</execute-query>

</html>

</xsp:page>

-------------test.xsl------------------------------
<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

   <xsl:template match="/*">
   	<body>
	<pre>
	<xsl:copy-of select="."/>
	</pre>
   	</body>
   </xsl:template>

</xsl:stylesheet>



bye,
heli
-- 
     __ __    __           __    __ __    _    __
    / // /__ / /_ _  __ __/ /_  / // /__ (_)__/ /__ ___ ____ ____ ____
   / _  / -_) /  ' \/ // / __/ / _  / -_) / _  / -_) _ `/ _ `/ -_) __/
  /_//_/\__/_/_/_/_/\_,_/\__/ /_//_/\__/_/\_,_/\__/\_, /\_, /\__/_/
                                                  /___//___/


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: database

Posted by Bernhard Huber <be...@a1.net>.
hi,

>
> has someone an example howto get an image out of a database (blob)
> and display it in html? 

Assuming your xsp/xsl pipe produces something like:
...<img src="image/a.gif"/>...

Now you may want in your sitemap matching image/*.gif to feed the image.
right?
thus your sitemap adds:
<map:match="image/*.gif">
<!-- image from db -->
</map:match>


now the interesting part is "image from db".
You might have to use a reader for doing that, as your gif image, is no 
xml, and will not get processed
by any XSL.
Cocoon knows so called reader: reading from file, and reading from db
in the sample sitemaps you find samples for using file readers, but 
propably not
for using db reader.
I don't know it by heart using the db-reader, and specifying your table, 
and column,
you might want to delve a bit into src.org.apache.cocoon.reader.*
hope it helps a bit

bye bernhard



---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>