tags:

views:

31

answers:

2

I have the following XPATH expression:

select="catalog/product/$category_name = $category_value"

In the given example $category_name and $category_value are the XSL parameters that I receive from my servlet and I want to use them in XSL to filter the XML result based on category and its value.However, for some reason when,say, $category_name parameter equals 'price' attribute of the 'product' parent node and $category_value equals 40, the given expression does not return any result at all! Logically, the expression should be transformed to something like select="catalog/product/price = 40"....I guess there is some problem with specifying the node name which is the category in my case. Can anyone suggest the way to get around this problem?

A: 

For variable xpath expressions, use dynamic xpath. See http://stackoverflow.com/questions/1551526/is-it-possible-to-use-a-dynamic-xpath-expression-in-a-xslt-style-sheet

mdma
+2  A: 

You probably want:

catalog/product/*[name()=$category_name] [. = $category_value]
Dimitre Novatchev