[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Best performant way to selectively find and process on

Subject: Best performant way to selectively find and process one node
From: "Luhar P" <luharp@xxxxxxxxx>
Date: Sun, 20 May 2007 13:37:37 -0700
 Best performant way to selectively find and process on
Hi,

I am newbie to xslt, so please excuse me if this sounds naive. Though
I know one way to get what i want, but i would like a more performant
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"?>
<bookstore>
<books>
<book>
  <bookId>1</bookId>
  <title lang="eng">Harry Potter</title>
  <price>29.99</price>
</book>
<book>
  <bookId>2</bookId>
  <title lang="eng">Learning XML</title>
  <price>39.95</price>
</book>
</books>
</bookstore>

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:template match="book">
<xslt:call-template name="GetBookDetails" >
  <xslt:with-param name="book_node" select
="bookstore/books/book[id=$book_id]"></xslt:with-param>
</xslt:call-template >
 </xslt:template>

Ideally, i would like to be able to do something like
<xslt:template match="bookstore/books/book[id=$book_id]">
  <xslt:apply templates/>
</xslt:template>
But i can not use vairables in match statement. I did search on
biglist and other places, but could not find related question.
I am sure this is very common scenario and i am missing something.

Thanks for you help,

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.