cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john.d.g...@bellatlantic.com
Subject Re: problems passing parameters to XSL templates
Date Wed, 12 Jan 2000 16:04:56 GMT



Hi Dave,

Are you using v1.5 or earlier? I am, and I encountered a similar problem. I
guess it relates to the XSLT processor, which
Cocoon at one time defaulted to the XSL:P processor. I am planning to switch
over to the new version of Cocoon and to use Xalan as the XSLT processor.
Hopefully then the problem will just go away. ( Does anyone know if this is the
case?? )

Based on the test case below, I guess the XSL:P processor does not accept
param's in a value-of, although variables seem to work. The way I read the spec,
this is, IMHO,  incorrect behaviour. Then again, maybe it does work and I just
don't understand parameter binding properly....

Section 7.6.1 of the XSLT 1.0 spec says:

"The xsl:value-of element is instantiated to create a text node in the result
tree. The required
  select attribute is an expression; this expression is evaluated and the
resulting object is converted to a
  string as if by a call to the string function. The string specifies the
string-value of the created text node."

Since $myParam is a valid string expression ( I think? where myParam is bound to
a string value? ), it should work the way you have it. I am guessing that
someone was inspired by the example in the preamble to section 7.6:

"Within a template, the xsl:value-of element can be used to compute generated
text, FOR EXAMPLE by
  extracting text from the source tree or by inserting the value of a variable."
 ( emphasis mine. note params are not mentioned).

Regards,
John Gray

P.S. - here is the test code and result:
 = = = = = = = = = = = = = = = = = = = = = = = =  XML  = = = = = = = = = = = = =
= = = = = = = = = = = = = = = = = = =

<?xml version="1.0"?>
<?xml-stylesheet href="paramtest.xsl" type="text/xsl"?>
<?cocoon-process type="xslt"?>

<somemaintag>
<sometesttag>
data
</sometesttag>
</somemaintag>

 = = = = = = = = = = = = = = = = = = = = = = = = XSL = = = = = = = = = = = = = =
= = = = = = = = = = = = = = = = = = =

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
indent-result="yes">

<xsl:template match="/" >
<html>
<body>
<h2>Param Test Result:</h2>
     <xsl:param name="param_value">PARAMDATA</xsl:param>
     <xsl:variable name="variable_value">VARIABLEDATA</xsl:variable>
     <xsl:variable name="null_value"></xsl:variable>
     variable value: <xsl:value-of select="$variable_value" /><br/>
     param value: <xsl:value-of select="$param_value" /><br/>
     null value: <xsl:value-of select="$null_value" /><br/>
     non-existant value: <xsl:value-of select="$non-existant" /><br/>
</body>
</html>
</xsl:template>

</xsl:stylesheet>

 = = = = = = = = = = = = = = = = = = = = = = = = OUTPUT  ( manually indented )
= = = = = = = = = = = = = = = = =

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/RED-html40/strict.dtd">
<html>
     <body>
          <h2>Param Test Result:</h2>
          variable value: VARIABLEDATA<br>
          param value: undefined<br>
          null value: <br>
          non-existant value: undefined<br>
     </body>
</html>
<!-- This page was served in 94 milliseconds by Cocoon 1.5 -->

 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
= = = = = = = = = = = = = = = = = = = =





"dave sag" <dave.sag@portablewhole.com> on 01/11/2000 02:06:45 PM

To:   cocoon-users@xml.apache.org
cc:    (bcc: John D. Gray)
Subject:  problems passing parameters to XSL templates



Hi gang,

I have a small template for building the <option... bits of an html popup menu.

here it is.

     <xsl:template name="dayOption">
               <xsl:param name="numb"/>
         <option value="{$numb}">
          <xsl:if test="date/@day = $numb">
               <xsl:attribute name="selected">true</xsl:attribute>
          </xsl:if><xsl:value-of select="$numb"/>
         </option>

     </xsl:template>


I call this template and pass parameters like so...

     <xsl:template name="editDate">
          <select name="date_day">
          <xsl:call-template name="dayOption"><xsl:with-param
name="numb">01</xsl:with-param></xsl:call-template>
          <xsl:call-template name="dayOption"><xsl:with-param
name="numb">02</xsl:with-param></xsl:call-template>
          <xsl:call-template name="dayOption"><xsl:with-param
name="numb">03</xsl:with-param></xsl:call-template>

          ... snip ...

          </select>

          ... snip ...

     </xsl:template>

what I end up with is a popup menu with the word 'undefined' wherever the params
 are used.
is there a known bug in the way cocoon passes params to templates,
 or have i done something clotheared?

tia

dave




----------------------------------------------------------
Dave Sag                            CEO Portable Whole Ltd
dave@portablewhole.com        http://www.portablewhole.com

  "Software Development will soon be an Agri-business.
   Why write it when you can farm it."

  Latest: http://www.davesag.com/motp
  It's a whole new world in there. (req netscape or IE 4+)

----------------------------------------------------------

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







Mime
View raw message