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