Subject: RE: [xsl] xsl with dynamic xpath statement from param and variable From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Thu, 6 Sep 2007 22:42:26 +0100 |
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > <xsl:output omit-xml-declaration="yes" indent="yes"/> > <xsl:param name="argDictItem">RT.VAL.CANCELDATE</xsl:param> > <xsl:variable name="sgl_qte">%27</xsl:variable> > <xsl:variable name="xpathDictItem" > select="concat('group/dict[@id=',$sgl_qte,$argDictItem,$sgl_qt > e,']/val') > "/> Firstly, you can't construct XPath expressions dynamically in standard XSLT. You need a processor that offers an extension such as saxon:evaluate() or dyn:evaluate(). Secondly, I can't see why you need it in this case. What's wrong with <xsl:variable name="xpathDictItem" select="group/dict[@id=concat($sgl_qte,$argDictItem,$sgl_qte)]/val"/> (Except it seems a bit odd: what are those "%27" strings doing there?) Thirdly, I don't know whether you can trust the caller who is supplying $argDictItem, but if you do use xx:evaluate then you need to check that $argDictItem doesn't contain any string delimiters. > <xsl:template match="node()"> > <xsl:if test="name()!='item'"> Having a template that matches all nodes, and then immediately testing what kind of node it is dealing with, seems a pretty odd thing to do. Michael Kay http://www.saxonica.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] xsl with dynamic xpath st, G. Ken Holman | Thread | [xsl] Templates, SINGH Navpreet |
RE: [xsl] Date comparasions, Michael Kay | Date | RE: [xsl] Templates, Michael Kay |
Month |