[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: variable in filter doesn't work??
[Carter, Will] > > why doesn't this work? > ----------------------- > <xsl:variable name="filter" select='"cat = > 'zoro'"'/> <xsl:value-of select="$filter"/> > <tr> > <td><xsl:value-of select="cat"/></td> > <td><xsl:value-of select="dog"/></td> > <td><xsl:value-of select="fish"/></td> > </tr> > </xsl:for-each> Aside from the fact that you have omitted the contents on the xsl:for-each start tag so we cannot be sure what you wrote, you cannot use a variable as a path expression. You are probably saying the equivalent of <xsl:for-each select='person["cat='zoro'"]'> This does not do any filtering because the predicate has to be either a number (to select a particular node by its position) or an expression. An expression gets evaluated as a boolean. A non-empty string evaluates to "true", so your statement is equivalent to <xsl:for-each select='person[true]'> This will select all person nodes as you have seen. You could write <xsl:variable name='filter' select='"zoro"'/> <xsl:for-each select='person[cat=$filter]'> This is not quite what you are after,it seems. You could get the effect you are trying for this way: <xsl:variable name='filter-element' select='"cat"'/> <xsl:variable name='filter-value' select='"zoro"'/> <xsl:for-each select="person[*[name()=$filter-element and text()=$filter-value]]"> Cheers, Tom P 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
|