Good way to select & process only one node
This is newbie question. Though I know one way to get what i want, but i would like a more better way to do it.
I have need to find and process only one node out of thousands and generate output for it.
The node needs to be selected based upon querystring value for book id and then processed by a template.
A simplified book structure is given below -
<?xml version="1.0" encoding="ISO-8859-1"?>
<title lang="eng">Harry Potter</title>
<title lang="eng">Learning XML</title>
One (IMO) non performant way of doing it is to have a template that matches books, select book with the correct id and pass it for processing to named template.
I am sure there is way to avoid matching all book nodes and then find the correct node to pass to named template.
For simplicity sake, i am assuming that the querystring book id value gets set in xslt variable (using xslt extensions) but right now is hardcoded to value 1.
<xslt:variable name="book_id" select="1">
<xslt:call-template name="GetBookDetails" >
<xslt:with-param name="book_node" select ="bookstore/books/book[id=$book_id]"></xslt:with-param>
Ideally, i would like to be able to do something like
But i can not use variables in match statement. I did search on forums, but could not find related question.
Thanks for you help,