[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] problem with Passing Parameters to Templates
Subject: Re: [xsl] problem with Passing Parameters to Templates From: David Carlisle <davidc@xxxxxxxxx> Date: Mon, 22 Jan 2001 15:25:33 GMT |
> Did I do something wrong? yes:-) Firstly the simple answer to your question: > What I really want to do is to output the value of element codec( appears to be <xsl:value-of select=".//codec"/> in which case you don't have any params to worry about, but to see what's wrong with your code node that you have defined $node to be a string. It is always the empty string or 'codec'. <xsl:if test=".//*[$node]"> this is using $node in a predicate so the string will be coerced to a boolean. If it is empty (ie if the named template is called without an explicit parameter) then it will have boolean value false *[false()] selects all elements for which false is true. .// searches for all descendents of the current node for which the above is true. As false is never true this will return the empty nosde set. This node set is used in an if test so will be coerced to boolean as false. So in this case the value-of clause will be skipped. If $node is codec then [$codec] is the same as [true()] so .//*[$codec] will be true if the current node has any element children and will be false otherwise. If it is true then the value-of will be evaluated. which will return the value of the first codec descendent. As you see the xsl:if isn't doing anything useful in either case you could just miss it out and say <xsl:value-of select=".//*[name()=$node]"/> If there are no elements of that name, you don't need to test with xsl:if, you just get nothing returned. David XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] problem with Passing Para, helen li | Thread | Re: [xsl] problem with Passing Para, helen li |
Re: [xsl] problem with Passing Para, helen li | Date | RE: [xsl] the problem of duplicatin, DPawson |
Month |