You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Mac Schwarz <mc...@phil.uni-erlangen.de> on 2000/08/22 14:25:56 UTC
How to use a taglib?
Hi,
given a xml file and a corresponding stylesheet like
-------- test.xml ---------
<?xml version="1.0"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="test.xsl" type="text/xsl"?>
<page>
<input/>
</page>
---------------------------
--------test.xsl-----------
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="page">
<xsp:page language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core"
xmlns:request="http://www.apache.org/1999/XSP/Request">
<head>
<title>Test</title>
</head>
<body>
<xsl:apply-templates/>
</body>
</xsp:page>
</xsl:template>
<xsl:template match="input">
<form action="test2.xml" method="post">
<input type="text" size="4" name="level"/>
<input type="submit" name="submit"/>
</form>
</xsl:template>
</xsl:stylesheet>
--------------------------
Now I have a input field and a submit button. After submitting the form
another xml file and stylesheet is called.
-------------test2.xml-------
<?xml version="1.0"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="test2.xsl" type="text/xsl"?>
<page>
<content>
<verbose>This is the verbose content</verbose>
</content>
</page
-----------------------------
-----------test2.xml---------
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsp="http://www.apache.org/1999/XSP/Core"
xmlns:request="http://www.apache.org/1999/XSP/Request">
<xsl:template match="page">
<xsl:processing-instruction
name="cocoon-process">type="xsp"</xsl:processing-instruction>
<xsl:processing-instruction
name="cocoon-format">type="text/html/loose"</xsl:processing-instruction>
<xsp:page language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core"
xmlns:request="http://www.apache.org/1999/XSP/Request">
<html>
<head>
<title>Test</title>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsp:page>
</xsl:template>
<xsl:template match="content">
Parameter Value: <request:get-parameter-values name="level"/><br/>
<xsl:variable name="mylevel"><request:get-parameter-values
name="level"/></xsl:variable>
Variable value: <xsl:copy-of select="$mylevel"/>
<xsl:if test="'$mylevel' = 'verbose'">
<br/>
<xsl:apply-templates select="verbose"/>
</xsl:if>
</xsl:template>
<xsl:template match="verbose">
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
---------------------
The text 'This is the verbose content' should be displayed if the
submittet text is 'verbose'.
However I only get a page with
Parameter Value: verbose
Variable value: verbose
but the <xsl:if part is never evaluated. The testcondition "'$mylevel' =
'verbose'" is never fulfilled. Works fine if I change it to "'verbose' =
'verbose'" but that's obviously not what I need.
Is there any trick to 'force' the evaluation of $mylevel?
mac
--
Mac Schwarz / AERIA Projekt / Inst. f. Klassische Archaeologie
e-mail: mac@aeria.phil.uni-erlangen.de / Tel.: 09131-85-24791
FAU Erlangen-Nuernberg / Kochstr.4 / 91054 Erlangen
<http://www.phil.uni-erlangen.de/~p1altar/aeriahome.html>