[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] can a value of a parameter depends on a other value
Subject: Re: [xsl] can a value of a parameter depends on a other value From: Mukul Gandhi <gandhi.mukul@xxxxxxxxx> Date: Thu, 1 Dec 2011 14:46:16 +0530 |
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. 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> 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"> ... This seems to be wrong. I think, a xsl:template match=".. template cannot receive a call from <xsl:call-template ... I think you need to modify the template, <xsl:template match="printdata"> ... to following, <xsl:template name="printdata"> <xsl:param name="articleperpage"> ... 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. so lot of errors! On Thu, Dec 1, 2011 at 1:45 PM, Roelof Wobben <rwobben@xxxxxxxxxxx> wrote: > > Hello, > > > > I tried your suggestion. See this : > > > > > > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet version="1.0" > B xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > > <xsl:output method="xml" > B doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" > B doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > B omit-xml-declaration="yes" > B encoding="UTF-8" > B indent="yes" /> > > > > <xsl:variable name="mycount" select="count(/data/artikel-details/entry)" /> > > > > <xsl:template match="/"> > B B <xsl:apply-templates select="/data/artikel-details/entry"/> > </xsl:template> > > > > <xsl:template match="printdata"> > B <h1><xsl:value-of select="titel"/></h1><br /> > B B <xsl:value-of select="datum" /><br /> > B B <xsl:value-of select="tekst" /> <br /> > </xsl:template> > > > > <xsl:template match="artikel-details/entry"> > B B <xsl:param name="articleperpage"/> > > B B <xsl:call-template name="printdata"> > B B B B <xsl:with-param name="articleperpage"> > B B B B B <xsl:choose> > B B B B B B B <xsl:when test="($month = '2005-02') and (number($page) = 1)">2</xsl:when> > B B B B B B B B <xsl:when test="($month = '2005-02') and (number($page) = 2)">3</xsl:when> > B B B B B <otherwise>1</otherwise> > B B B B </xsl:choose> > B B </xsl:with-param> > B </xsl:call-template> > </xsl:template> > > > </xsl:stylesheet> > > > > > > > > But now I get a message that the called template printdata is not found. > > What am I doing wrong here ? > > > > Roelof -- Regards, Mukul Gandhi
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] can a value of a paramete, Roelof Wobben | Thread | RE: [xsl] can a value of a paramete, Roelof Wobben |
RE: [xsl] can a value of a paramete, Roelof Wobben | Date | Re: [xsl] XPath equivalence questio, Hermann Stamm-Wilbra |
Month |
Keywords