This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
passing parameters to template using the cand.rec. nov 2000
- To: XSL-List at lists dot mulberrytech dot com
- Subject: [xsl] passing parameters to template using the cand.rec. nov 2000
- From: hedwig_de_roos at motosoto dot com
- Date: Tue, 17 Jul 2001 14:01:14 +0200
- Reply-To: xsl-list at lists dot mulberrytech dot com
I used the XSLT version 1.0 (w3c Recommendation 16 November 1999) before
and I never had problems passing parameters to a template. Now I am
using Extensible Stylesheet Language version 1.o (W3C Candidate
Recommendation 21 November 2000) and my stylesheet does not work
anymore.
Here is the XML I am using:
<?xml version="1.0"?>
<root>
<result>
<row>
<prof_ref>1</prof_ref>
<prof_type>document</prof_type>
<prof_name>Reflections on Java, Beans and
relational databases</prof_name>
<prof_extra>0</prof_extra>
<ranking>100</ranking>
</row>
<row>
<prof_ref>2</prof_ref>
<prof_type>document</prof_type>
<prof_name>Java Components</prof_name>
<prof_extra>0</prof_extra>
<ranking>100</ranking>
</row>
</result>
</root>
And this is my XSL-sheet:
<xsl:template match="/">
<xsl:apply-templates select="root/result"/>
</xsl:template>
<xsl:template match="result">
<html>
<body bgcolor="#ffffff" background="art/maincontent_bckgrnd.gif"
topmargin="0" bottommargin="0" leftmargin="0" marginheight="0"
marginwidth="0" >
<table border="0" cellpadding="0" cellspacing="4" width="90%">
<tr>
<td colspan="3" align="left" valign="top">
<xsl:call-template name="getContentLabel"/>
</td>
</tr>
<xsl:for-each select="row">
<xsl:sort data-type="number" select="ranking"
order="descending"/>
<tr>
<td>
<font size="2" face="Arial, Helvetica, sans-serif">
<a target="maincontent"><xsl:attribute
name="href"><xsl:call-template name="getHref"><xsl:with-param name="id"
select="prof_ref"/><xsl:with-param name="type"
select="prof_type"/></xsl:call-template></xsl:attribute>
<!--display result , choose needed for display -->
<xsl:value-of select="prof_name"/>
</a>
</font></td>
<td>
<font size="2" face="Arial, Helvetica, sans-serif">
<xsl:if test="prof_extra != 0">
<xsl:value-of select="prof_extra"/>
</xsl:if>
</font></td>
<td>
<font size="2" face="Arial, Helvetica, sans-serif">
score: <xsl:value-of select="ranking"/>
</font></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
<xsl:template name="getHref">
<xsl:choose>
<xsl:when test="$type='document'">
/community.mts?eventid=news_frame&newsid=<xsl:value-of
select="$id"/>
</xsl:when>
<xsl:when test="$type='user_skill' or $type='user_interest'">
/community.mts?eventid=yp_groupdetail&memberid=<xsl:value-of
select="$id"/>
</xsl:when>
<xsl:when test="$type='group_member_skill' or
$type='group_member_interest' or $type='group_content'">
/community.mts?eventid=ghp&groupid=<xsl:value-of select="prof_ref"/>
</xsl:when>
<xsl:otherwise>
#
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="getContentLabel">
<xsl:choose>
<xsl:when test="//prof_type='document'">
<img src="art/contentlabel_asearch_documents.gif" border="0"/>
</xsl:when>
<xsl:when test="//prof_type='user_skill' or
//prof_type='user_interest'">
<img src="art/contentlabel_asearch_people.gif" border="0"/>
</xsl:when>
<xsl:when test="//prof_type='group_content' or
//prof_type='group_member_skill' or
//prof_type='group_member_interest'">
<img src="art/contentlabel_asearch_groups.gif" border="0"/>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
And this is the error that I get:
file:///var/home/hedwig/bin/w3c.xsl; Line 50; Column 13;
VariableReference given for variable out of context or without
definition! Name = type
I really do not understand how I can use the <xsl:with-param>
functionality work with this new processor.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list