1

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?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Alex
  • 441
  • 1
  • 6
  • 15

2 Answers2

2

You probably want:

catalog/product/*[name()=$category_name] [. = $category_value]
Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431
0

For variable xpath expressions, use dynamic xpath. See Is it possible to use a Dynamic xPath expression in a xslt style sheet?

Community
  • 1
  • 1
mdma
  • 56,943
  • 12
  • 94
  • 128