Subject: Re: WG: [xsl] RPN calculator From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 2 May 2002 13:47:40 +0100 |
Hi Costantino, > Regarding Jeni's answer, actually I do not understand the purpose of > using a mode (besides learning something new for me...). And I tried > it, but it doesn't work, I think because it enters the multiply or > sum templates without the "calculate" mode. Yes, sorry -- I should have said "To do the calculation, apply templates to the equation in 'calculate' mode." So do something like: <xsl:template match="/"> <xsl:apply-templates mode="calculate" /> </xsl:template> I usually use modes when I want to do something with a bit of XML that isn't simply giving the textual output from that XML. In your case, for example, you might want to actually print out the equation with some normal templates like: <xsl:template match="multiply"> <xsl:text>(</xsl:text> <xsl:apply-templates select="arg1" /> <xsl:text> * </xsl:text> <xsl:apply-templates select="arg2" /> <xsl:text>)</xsl:text> </xsl:template> <xsl:template match="sum"> <xsl:text>(</xsl:text> <xsl:apply-templates select="arg1" /> <xsl:text> + </xsl:text> <xsl:apply-templates select="arg2" /> <xsl:text>)</xsl:text> </xsl:template> <xsl:template match="text()"> <xsl:value-of select="normalize-space()" /> </xsl:template> And then have the result of the stylesheet actually be governed through: <xsl:template match="/"> <xsl:apply-templates /> <xsl:text> = </xsl:text> <xsl:apply-templates mode="calculate" /> </xsl:template> That's my excuse for using a mode, anyway. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
WG: [xsl] RPN calculator, Costantino . Sertori | Thread | AW: WG: [xsl] RPN calculator, Costantino . Sertori |
Re: [xsl] RPN calculator, Oleg Tkachenko | Date | Re: [xsl] using mode-values within , David Carlisle |
Month |