Subject: Re: [xsl] math From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Wed, 30 May 2001 11:32:31 +0100 |
Hi Ronald, > How can I do this with XSLT, for all I seem to get for output is the > string: "500 div 50 * 10" in stead of 100. You can't dynamically evaluate an expression in pure XSLT 1.0. However, some processors, such as Saxon, have an evaluate() extension function that will allow you to do so. If you're using Saxon, you can do: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://icl.com/saxon" extension-element-prefixes="saxon"> <xsl:output method = "html" encoding="Windows-1252" /> <xsl:template match="/"> <xsl:variable name="expr"> <xsl:apply-templates select="math"/> </xsl:variable> <html> <head></head> <body><xsl:value-of select="saxon:evaluate($expr)"/></body> </html> </xsl:template> </xsl:stylesheet> Xalan has a similar evaluate() extension function. If you're using MSXML, I'm afraid that I don't know of any similar extension function for full XPath expressions (although you can use it to evaluate location paths with a user-defined function through msxsl:script). I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] href attributes, Swen Thuemmler | Thread | RE: [xsl] math, Michael Kay |
Re: [xsl] Convert XML elements with, Jeni Tennison | Date | [xsl] variables, Mengel Andre (FV/SLM |
Month |