RE: [xsl] Cannot use result tree fragment

Subject: RE: [xsl] Cannot use result tree fragment
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Wed, 18 Jun 2003 12:40:57 -0400
[abbouh]
> i want to get all "ht"  nodes from different  external documents,so i
> use in my xsl file:
> 
> <xsl:for-each select="//doccontent/chapmod">
> <xsl:variable name="vchapmod" select="current()"/>
> <xsl:variable name="vchapmod1">
> <xsl:value-of
> select="document(concat(string($vchapmod/attribute::docref),'.
> xml'))"/>
> </xsl:variable>
> <xsl:for-each select="$vchapmod1//ht">
> 
> but i get this error :
> Error in Xpath expression,Cannot use result tree fragment
> the error is for <xsl:for-each select="$vchapmod1//ht">
> 

When you tell the stylesheet to create a result, it gets stored as a
"Result Tree Fragment" (RTF).  In xslt 1.0, RFTs cannot be used in place
of nodesets, so you cannot operate on the output.  Some processors have
an extension that does let you use them as if they were regular
nodesets.

When you declare a variable the way you did, the processor creates a RTF
and assigns it to the variable.  That is why you got the error message.

But you could simplify you variable and get the result you expected -

<xsl:variable name="vchapmod1" 
 
select="document(concat(string($vchapmod/attribute::docref),'.xml'))"/>

In this construction, you select a nodeset and assign it to the
variable, so you will be able to use it.

Cheers,

Tom P

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


Current Thread