Hi, Peter.

news <[EMAIL PROTECTED]> wrote on 2008-04-17 09:48:00 AM:
> I'm trying to convert a result tree fragment into a nodeset using
> xsl:copy-of. From the w3c spec, if I understand it correct, this should 
be
> possible:
> 
> "When a result tree fragment is copied into the result tree (see [11.3 
Using
> Values of Variables and Parameters with xsl:copy-of]), then all the 
nodes
> that are children of the root node in the equivalent node-set are added 
in
> sequence to the result tree."
> 
> I'm using the following piece of code: <xsl:variable
> name="node"><node><xsl:copy-of 
select="$fragment"/></node></xsl:variable>
> 
> The following error occurs in this line: "#RTREEFRAG kann nicht in 
NodeList
> konvertiert werden!"

As Joe was pointing out, there are restrictions on the operations that may 
be performed on a result tree fragment (nodes constructed by the 
stylesheet, rather than read from the input document).  Section 11.1 of 
XSLT 1.0 [1] has this to say, "An operation is permitted on a result tree 
fragment only if that operation would be permitted on a string (the 
operation on the string may involve first converting the string to a 
number or boolean). In particular, it is not permitted to use the /, //, 
and [] operators on result tree fragments."  However, it goes on to say, 
"When a result tree fragment is copied into the result tree (see [11.3 
Using Values of Variables and Parameters with xsl:copy-of]), then all the 
nodes that are children of the root node in the equivalent node-set are 
added in sequence to the result tree," so the xsl:copy-of operation should 
not be a problem (unless there's a bug in the processor, but I've not been 
able to reproduce that.

So, the first question must be, are you attempting to use / or // or [] 
operators on a result tree fragment?

and later...

news <[EMAIL PROTECTED]> wrote on 2008-04-17 05:02:33 PM:
> Hm, might it have to do with building the fragment using a key on an 
> external document?
> 
> I've been using sth like this:
> <xsl:variable name="external" select="document('ext.xml')"/>
> <xsl:variable name="fragment">
>    <xsl:for-each select="$fragment">
>      <xsl:copy-of select="key(...)"/>
>    </xsl:for-each>
> </xsl:variable>

Probably not.  Doing an xsl:copy-of on a result tree fragment is always 
permitted - it doesn't matter how it was constructed.

As I said, the usual reason for this error is that you are attempting to 
apply a path expression (/, // or [] operators) to a result tree fragment. 
 If that's not the case, please produce a complete, stand-alone stylesheet 
with input that demonstrates the problem - otherwise, we're all just 
making guesses at what might be going wrong.

Thanks,

Henry
[1] http://www.w3.org/TR/xslt#section-Result-Tree-Fragments
------------------------------------------------------------------
Henry Zongaro
XML Transformation & Query Development
IBM Toronto Lab   T/L 313-6044;  Phone +1 905 413-6044
mailto:[EMAIL PROTECTED]

Reply via email to