----------------------------------------
From: gandhi(_dot_)mukul(_at_)gmail(_dot_)com
Date: Thu, 1 Dec 2011 14:46:16 +0530
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] can a value of a parameter depends on a other value
Hi Roelof,
Here are couple of things I can see wrong in the stylesheet you've posted,
1. you've a variable declaration <xsl:variable name="mycount" ... but
you don't make use of this variable in the stylesheet.
Im going to use this variable later on. I try to rewrite my code.
2. you've a template definition
<xsl:template match="artikel-details/entry">
<xsl:param name="articleperpage"/>
...
which you're seemingly calling as,
<xsl:template match="/">
<xsl:apply-templates select="/data/artikel-details/entry"/>
...
This is wrong, since you don't pass an argument matching the template
parameter. If you need a parameter in this template, then you should
call the template as follows,
<xsl:apply-templates select="/data/artikel-details/entry">
<xsl:with-param name="articleperpage" select="{provide a value OR
compute}"/>
</xsl:apply-templates>
I think this is not going to work. The parameter articleperpage gets later on a
value based on 2 parameters.
3. In the template definition,
<xsl:template match="artikel-details/entry">
...
you make a call to a named template as follows,
<xsl:call-template name="printdata">
<xsl:with-param name="articleperpage">
...
To handle this template call, it seems you've defined this template,
<xsl:template match="printdata">
...
Oke,
What I was trying to make this part :
<!-- Named template definition: printdata -->
<xsl:template name="printdata">
<xsl:param name="articleperpage"/> <!-- parameter declaration -->
<!-- Template logic -->
</xsl:template>
<xsl:call-template name="printdata">
<xsl:with-param name="articleperpage"> <!-- parameter value to pass to named
template -->
<xsl:choose>
<xsl:when test="($month = '2005-02') and (number($page) = 1)">2</xsl:when>
<xsl:when test="($month = '2005-02') and (number($page) = 2)">3</xsl:when>
<otherwise>1</otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
to work into this template :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
omit-xml-declaration="yes"
encoding="UTF-8"
indent="yes" />
<xsl:variable name="mycount" select="count(/data/artikel-details/entry)" />
<xsl:template match="/">
<xsl:apply-templates select="/data/artikel-details/entry"/>
</xsl:template>
<xsl:template match="artikel-details/entry">
<h1><xsl:value-of select="titel"/></h1><br />
<xsl:value-of select="datum" /><br />
<xsl:value-of select="tekst" /> <br />
</xsl:template>
</xsl:stylesheet>
But I did it appearently very wrong.
...
4. In the template call,
<xsl:call-template name="printdata">
<xsl:with-param name="articleperpage">
<xsl:choose>
<xsl:when test="($month = '2005-02') and (number($page) =
1)">2</xsl:when>
<xsl:when test="($month = '2005-02') and (number($page) =
2)">3</xsl:when>
<otherwise>1</otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
you use variable references $month and $page. these variable
references were not declared before, which is wrong.
The are declared by Symphomny CMS which I use to make this website.
Roelof
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--