|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: dynamic sorting
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








