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

RE: dynamic sorting

Subject: RE: dynamic sorting
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 6 Feb 2004 00:14:44 -0000
xpath local name sort
> Thanks for pointing it out. I have one more question:
> 
> But how do I combine test="self::book:title" with a variable 
> $sort, which will contain in this situation "title". 

You can only use self::x if you know the name x statically.

What exactly is the string contained in variable $sort? Is it a lexical
QName, of the form "[p:]xyz". If so, what does the prefix "p" mean; what
namespace context should be used to interpret it? If you confine
yourself to names in no namespace, you're OK to use [name()=$sort], but
as soon as you want to handle names in a namespace, you really need two
parameters, one for the namespace URI and one for the local name, and to
write the test as [local-name()=$sort-1 and namespace-uri()=$sort-2]. Or
in XSLT 2.0 you can use a variable of type xs:QName instead of using a
string, and test [node-name() = $qname].

Incidentally, dynamic XPath evaluation (xx:evaluate()) also suffers from
this problem. There is no way of writing a general XPath expression that
isn't dependent on its namespace context, which means that manipulating
XPath expressions as strings is intrinsically error-prone.

Michael Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.