|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: WG: RPN calculator
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








