Because you didn't supply a complete self-contained stylesheet I had to make modifications to prevent spurious errors. After these modifications I got an error different from yours, but similar: it objected to the line
[code]
<xsl:value-of select="/workfile/query/consultant[@calendar-id=$calendar-id]/@code" />
[code]
saying
Error on line 166 of test.xsl:
XPTY0020: Leading '/' cannot select the root node of the tree containing the context item:
the context item is an atomic value
I fix this by replacing /workfile/query with $query.
I now get a similar error a few lines further on, with the code
Code:
<xsl:value-of select="id" />
I don't know how to fix this, because I don't know where you are expecting to find the "id" element. So I deleted the line, and it now compiles OK.
It seems to me that you haven't really understood the XSLT concept of the context item. When you do a for-each, or apply-templates, each node or item you are processing becomes the context item. When you use a path expression, it is relative to the context item. When you do for-each select="tokenize(...)", then inside the for-each the context item is a string, and you can't use a path expression that is relative to a string (it has to be a node). The solution is to bind a variable to the relevant node outside the for-each, and use that variable at the start of your paths. It doesn't have to be a global variable, of course.