On Thu, Sep 20, 2012 at 12:11 AM, Michael Kay <mike(_at_)saxonica(_dot_)com>
wrote:
Ihe,
Your stylesheet contains the element
<this:fieldName elem="productThumbnail" plural="thumbnails"
bracketType="{{"/>
as part of the definition of a global variable. If this is executed as a
literal result element the result will be the element
<this:fieldName elem="productThumbnail" plural="thumbnails"
bracketType="{"/>
(with a single "{").
But you are not executing it as a literal result element, you are reading it
from the source XML of the stylesheet using the function call doc(''). In
elements read from source documents, curly braces have no special
significance, so "{{" represents itself. If the element were in a normal
source document, then bracketType="{" would work fine, but because the
element has a dual role (as an element in a source document and as a literal
result element in a stylesheet), bracketType="{" is an error.
The idea of reading the source document using document('') is a hack used in
XSLT 1.0 to get around the restrictions on using result tree fragments. It
is never needed in XSLT 2.0: use the global variable directly. (It's also a
very inefficient hack, because the stylesheet has to be parsed twice.)
I resorted to that hack because if I have this
<xsl:variable name="this" as="node()">
<this:desiredFields>
<product/><m__id/>...........<productThumbnail/>
</this:desiredFields>
</xsl:variable>
and then try to use the variable $this as the third parameter in a
call to the key function I get
net.sf.saxon.trans.XPathException: In the key() function, the node
supplied in the third argument (or the context node if absent) must be
in a tree whose root is a document node
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--