You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Orgalist <or...@wanadoo.fr> on 2001/08/24 16:22:09 UTC

[C2b2] esql tags in xsl stylesheets

I can't make it work, the esql tags are not interpreted
i also use esql tags in file.xsp where it works
if someone can help me thanks.
(I know similar questions have been posted, but i could find a solution
in the answers )

C.

here's the namespace in my xsp file
===============file.xsp=======
<xsp:page
	language="java"
	xmlns:xsp="http://apache.org/xsp"
	xmlns:esql="http://apache.org/cocoon/SQL/v2"
>
...
</xsp:page>
========================

the part of the xsl i'd like to see working :
==========file.xsl=====================
<?xml version="1.0" encoding="ISO-8859-1"?>


<xsl:stylesheet version="1.0"

	xmlns:esql="http://apache.org/cocoon/SQL/v2"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

>

<xsl:template match="columns" mode="add">
	<xsl:apply-templates select="col" mode="add"/>
</xsl:template>

<xsl:template match="col" mode="add">
<xsl:variable name="nom"><xsl:value-of select="name/."/></xsl:variable>
<xsl:variable name="type"><xsl:value-of select="type/."/></xsl:variable>
<xsl:if test="$nom!='id'">
<td>

	<xsl:choose>
		<xsl:when test="starts-with($nom, 'text_')">
		<xsl:value-of select="substring-after($nom,'_')"/>
		</xsl:when>
		<xsl:otherwise>
		<xsl:value-of select="$nom"/>
		</xsl:otherwise>
	</xsl:choose>

	<xsl:choose>
		<xsl:when test="starts-with($nom, '_')">

		<esql:connection>
		<esql:driver>org.gjt.mm.mysql.Driver</esql:driver>
		<esql:dburl>jdbc:mysql://xxxxxx/listes</esql:dburl>
		<esql:username>****</esql:username>
		<esql:password>*****</esql:password>

		<esql:execute-query>
		<esql:query>
		select * from <esql:parameter><xsl:value-of
select="substring-after(substring-before($nom,'__'),'_')"/></esql:parameter>
		</esql:query>
		<esql:results>
		<esql:row-results>
			<esql:get-string column="type"/>
		</esql:row-results>
		</esql:results>
		</esql:execute-query>

		</esql:connection>

		</xsl:when>
		<xsl:otherwise>

		</xsl:otherwise>
	</xsl:choose>

</td>
</xsl:if>
</xsl:template>


---------------------------------------------------------------------
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: [C2b2] esql tags in xsl stylesheets

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 24.Aug.2001 -- 05:04 PM, Arnaud Vandyck wrote:
> Response below...
> 
> Date: Fri, 24 Aug 2001 16:22:09 +0200
> From: "Orgalist" <or...@wanadoo.fr>
> 
> > I can't make it work, the esql tags are not interpreted
> > i also use esql tags in file.xsp where it works
> > if someone can help me thanks.
> > (I know similar questions have been posted, but i could find a solution
> > in the answers )
> > 
> > C.
> > 
> > here's the namespace in my xsp file
> > ===============file.xsp=======
> > <xsp:page
> > 	language="java"
> > 	xmlns:xsp="http://apache.org/xsp"
> > 	xmlns:esql="http://apache.org/cocoon/SQL/v2"
> > >
> > ...
> > </xsp:page>
> > ========================
> > 
> > the part of the xsl i'd like to see working :
> > ==========file.xsl=====================
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> > 
> > <xsl:stylesheet version="1.0"
> > 
> > 	xmlns:esql="http://apache.org/cocoon/SQL/v2"
> > 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > 
> > >
> 
> Impossible to do that! 
> 
> The esql *must* be in an xsp or xml page, never in the stylesheet. The
> esql tags  will be removed when  processing by Cocoon so  you even can
> not match esql tags in xsl. Read the docs/samples/xsp/esql.xsp example
> or the  employee examples (see the  sitemap to know where  to find it,
> must be in docs/samples/forms/employee.x* (xsp and xml)). 

If it hasn't changed recently, this is not true. Otherwise it would be
impossible to chain taglibs. It is perfectly OK to use esql in a
taglib stylesheet. Actually, the code looks quite OK to me and I don't
have a clue why it shouldn't work.

Note that differentiating between taglib stylesheets and formating
stylesheets is important here: I usually refer to the former only as
taglib and to the latter as stylesheet. Arnaud is right about any
logic in stylesheets (including of course the use of esql), while I
refer above only to taglibs.

Unfortunately, orgalist didn't specify which he is refering to. But if
it didn't work, he could have meant indeed stylesheets. Orgalist,
please have a look at the sql transformer then, this might be the way
to go.

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
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: [C2b2] esql tags in xsl stylesheets

Posted by Arnaud Vandyck <ar...@ressource-toi.org>.
Response below...

Date: Fri, 24 Aug 2001 16:22:09 +0200
From: "Orgalist" <or...@wanadoo.fr>

> I can't make it work, the esql tags are not interpreted
> i also use esql tags in file.xsp where it works
> if someone can help me thanks.
> (I know similar questions have been posted, but i could find a solution
> in the answers )
> 
> C.
> 
> here's the namespace in my xsp file
> ===============file.xsp=======
> <xsp:page
> 	language="java"
> 	xmlns:xsp="http://apache.org/xsp"
> 	xmlns:esql="http://apache.org/cocoon/SQL/v2"
> >
> ...
> </xsp:page>
> ========================
> 
> the part of the xsl i'd like to see working :
> ==========file.xsl=====================
> <?xml version="1.0" encoding="ISO-8859-1"?>
> 
> <xsl:stylesheet version="1.0"
> 
> 	xmlns:esql="http://apache.org/cocoon/SQL/v2"
> 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> 
> >

Impossible to do that! 

The esql *must* be in an xsp or xml page, never in the stylesheet. The
esql tags  will be removed when  processing by Cocoon so  you even can
not match esql tags in xsl. Read the docs/samples/xsp/esql.xsp example
or the  employee examples (see the  sitemap to know where  to find it,
must be in docs/samples/forms/employee.x* (xsp and xml)). 

Hope it helps,

--Arnaud

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