You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Nicki Møller <ni...@yahoo.dk> on 2000/07/19 16:55:54 UTC
Re: A simple xsl:if question from a XSL-newbie. Part II
Hi sudhi,
I tried to do the changes you suggested and it worked
(Thanxs) but I needed to change the contents of the
day-tag with a hardcoded date like "19-07-2000" to get
it working. When I try to use requested date it still
doesn't work.
Is there some basic problems with the request function
or am I just using it wrong???
Here is the exact code I have
----------------
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="page">
<xsl:processing-instruction
name="cocoon-format">type="text/wml"</xsl:processing-instruction>
<wml>
<head>
<meta http-equiv="Content-Type" content="text/wml;
charset=iso-8859-1"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>
</head>
<card id="events" title="{day}">
<do type="prev"><prev/></do>
<p align="center">
<xsl:value-of select="day"/><br/>
-------
<xsl:for-each select="ROWSET/ROW">
<xsl:if test="substring(Starttime, 1, 10) = //day">
It Worked!!!!!
</xsl:if>
<br/>
<xsl:value-of select="substring(Starttime, 1,
10)"/>
</xsl:for-each>
</p>
</card>
</wml>
</xsl:template>
</xsl:stylesheet>
----------------
And here is my XML
----------------
<?xml version="1.0"?>
<?cocoon-process type="sql"?>
<?cocoon-process type="xsp"?>
<?xml-stylesheet href="dayEvents.xsl" type="text/xsl"
media="wap"?>
<?cocoon-process type="xslt"?>
<xsp:page
language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core"
>
<xsp:structure>
<xsp:include>java.lang.*</xsp:include>
<xsp:include>java.text.*</xsp:include>
<xsp:include>java.sql.*</xsp:include>
</xsp:structure>
<page>
<xsp:logic>
String day = request.getParameter ("day");
day.trim();
</xsp:logic>
<connectiondefs>
<connection name="foo_connection">
<driver>org.gjt.mm.mysql.Driver</driver>
<dburl>jdbc:mysql://localhost:3306/house1</dburl>
<username>house1</username>
<password>none</password>
</connection>
</connectiondefs>
<query connection="foo_connection">
SELECT Event_Id, Body, Starttime, Endtime FROM Events
ORDER BY Event_Id
</query>
<day><xsp:expr>day</xsp:expr></day>
</page>
</xsp:page>
----------------
Thanxs again
Nicki
--- sudhi <su...@insage.com> skrev: > Hi,
> I dont think that will work....
> U have to do something like this...
>
> Here is the xsl..
> ----------------------------------------
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:template match="page">
> <xsl:processing-instruction
>
name="cocoon-format">type="text/html"</xsl:processing-instruction>
> <HTML>
> <HEAD>
> <TITLE><xsl:value-of select="TITLE"/></TITLE>
> <META HTTP-EQUIV="Content-Type"
> CONTENT="text/html;
> charset=UTF-8"/>
> <LINK HREF="/css/insage.css" REL="STYLESHEET"
> TYPE="text/css"/>
> </HEAD>
> <BODY BGCOLOR="#FFFFFF" TEXT="#000099"
> LINK="#000000"
> VLINK="#000000" ALINK="#666666" LEFTMARGIN="0"
> TOPMARGIN="0"
> BOTTOMMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0">
> <xsl:for-each select="ROWSET/ROW">
> <xsl:if test="substring(Starttime, 1,
> 10)=//Time">
> <xsl:value-of select="Body"/>
> </xsl:if>
> </xsl:for-each>
> </BODY>
> </HTML>
> </xsl:template>
> </xsl:stylesheet>
> ----------------------------------------
> and here is the xml
> ----------------------------------------
> <?xml version="1.0" standalone="no"?>
> <?cocoon-process type="xslt"?>
> <?xml-stylesheet href="test.xsl" type="text/xsl"?>
>
> <page>
> <Time>19-11-2000</Time>
>
> <ROWSET>
> <ROW id="0"><Starttime>19-11-2000
> 15:03</Starttime><Body>blablablablabla</Body></ROW>
> <ROW id="1"><Starttime>15-11-2000
> 13:40</Starttime><Body>some
> stuf</Body></ROW>
> <ROW id="2"><Starttime>19-11-2000
> 10:00</Starttime><Body>some more
> stuf</Body></ROW>
> </ROWSET>
> </page>
> ----------------------------------------
> The problem is...when u r getting substring of
> Strttime, u r inside
> ROWSET/ROW, u dont have an element called Time under
> that... so u have
> to use //Time to refer to the Time element.
> One more thing is I modified Time element to ..
> <Time>19-11-2000</Time>
>
> from
> <Time>
> 19-11-2000
> </Time>
> It didn't work this way, b'cos of space before it. U
> have to trim the
> space around it.
>
> HTH
> Sudhi
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> cocoon-users-help@xml.apache.org
>
______________________________________________________
Do You Yahoo!?
Få en gratis @yahoo.dk-adresse på http://mail.yahoo.dk
Re: A simple xsl:if question from a XSL-newbie. Part II
Posted by sudhi <su...@insage.com>.
U dont have a day element around xsp:logic like this...
<day>
<xsp:logic>
String day = request.getParameter ("day");
day.trim();
</xsp:logic>
</day>
HTH
sudhi