[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] org.apache.xpath.objects.XRTreeFrag error


Subject: RE: [xsl] org.apache.xpath.objects.XRTreeFrag error
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 26 Mar 2007 09:32:01 +0100

You haven't shown us the code that calls check_identical. This may need
similar changes.

It also seems that you haven't yet understood the explanation of what this
error message means. When you use xsl:variable, xsl:param, or xsl:with-param
in XSLT 1.0 you are creating a result tree fragment. The only things XSLT
1.0 allows you to do with an RTF are to convert it to a string or to copy it
(using xsl:copy-of). In particular you can't use it in a path expression.
This restriction is removed in XSLT 2.0. In 1.0 you can usually get around
it, if you need to, by calling the xx:nodeset() extension function available
in most products. But the code you showed us was creating RTFs quite
unnecessarily, and the better solution is to avoid creating them if you
don't need them.


Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Lepoldo Melo [mailto:leopoldosmj@xxxxxxxxxxxx]
> Sent: 26 March 2007 03:29
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Res: [xsl] org.apache.xpath.objects.XRTreeFrag error
>
> I've already done the changes, but I'm still getting the
> error on line "<xsl:for-each select="$node/*/*">". I don't
> know how to avod this tree fragment.
>
> The new code is bellow.
>
>     <xsl:template name="check_identical">
>         <xsl:param name="comp1"/>
>         <xsl:param name="comp2"/>
>         <xsl:variable name="string1">
>             <xsl:call-template name="stringify">
>                 <xsl:with-param name="node" select="$comp1"/>
>             </xsl:call-template>
>         </xsl:variable>
>         <xsl:variable name="string2">
>             <xsl:call-template name="stringify">
>                 <xsl:with-param name="node" select="$comp2"/>
>             </xsl:call-template>
>         </xsl:variable>
>         <xsl:value-of select="$string1=$string2"/>
>     </xsl:template>
>
>     <xsl:template name="stringify">
>         <xsl:param name="node"/>
>         <xsl:for-each select="$node/*/*">
>             <xsl:choose>
>                 <xsl:when test="boolean(local-name())">&lt;
>                     <xsl:value-of select="local-name()"/>
>                     <xsl:variable name="pos" select="position()"/>
>                     <xsl:for-each select="@*">
>                         <xsl:text> </xsl:text>
>                         <xsl:value-of
> select="local-name()"/>="<xsl:value-of select="."/>"</xsl:for-each>
>                     <xsl:call-template name="stringify">
>                         <xsl:with-param name="node" select="."/>
>                     </xsl:call-template>&lt;/
>                     <xsl:value-of
> select="local-name()"/>&gt;</xsl:when>
>                 <xsl:otherwise>
>                     <xsl:value-of select="normalize-space(.)"/>
>                 </xsl:otherwise>
>             </xsl:choose>
>         </xsl:for-each>
>     </xsl:template>
>
>
> Thanks a lot.
> Leopoldo
>
>
> ----- Mensagem original ----
> De: Michael Kay <mike@xxxxxxxxxxxx>
> Para: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Enviadas: Domingo, 25 de Margo de 2007 20:42:07
> Assunto: RE: [xsl] org.apache.xpath.objects.XRTreeFrag error
>
> If you make the changes to avoid the unnecessary copying of
> data into result tree fragments (as suggested in my earlier
> response) then you should not be getting this error.
>
> Michael Kay
> http://www.saxonica.com/
>
> > -----Original Message-----
> > From: Lepoldo Melo [mailto:leopoldosmj@xxxxxxxxxxxx]
> > Sent: 26 March 2007 00:26
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: Res: [xsl] org.apache.xpath.objects.XRTreeFrag error
> >
> > My code is ok, but it doesn't work with Xalan 2.5.2.
> >
> > The error is described at
> >
> http://www.biglist.com/lists/xsl-list/archives/200505/msg00391.html.
> >
> > The XRTreeFrag error happens on line "<xsl:for-each
> > select="$node/*/*">".
> >
> > ----- Mensagem original ----
> > De: Florent Georges <darkman_spam@xxxxxxxx>
> > Para: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Enviadas: Domingo, 25 de Margo de 2007 14:29:34
> > Assunto: Re: [xsl] org.apache.xpath.objects.XRTreeFrag error
> >
> > Lepoldo Melo wrote:
> >
> >   Hi
> >
> > > Okay. Thanks, but I still don't know how to solve the line
> > > "<xsl:for-each select="$node/*/*">".
> >
> >   What do you mean by "solving"?
> >
> >   Your code seems ok with that, both in XSLT 1.0 and 2.0
> (as long as
> > in XSLT 1.0 you pass a reference to an input tree, and what
> you showed
> > is not enough to be sure on that point).
> >
> >   So what exactly is the problem?
> >
> >   Regards,
> >
> > --drkm
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > ______________________________________________________________
> > _____________
> > Dicouvrez une nouvelle fagon d'obtenir des riponses ` toutes vos
> > questions !
> > Profitez des connaissances, des opinions et des expiriences des
> > internautes sur Yahoo! Questions/Riponses
> http://fr.answers.yahoo.com
> >
> >
> >
> >
> >
> > __________________________________________________
> > Fale com seus amigos  de graga com o novo Yahoo! Messenger
> > http://br.messenger.yahoo.com/
>
>
>
>
>
> __________________________________________________
> Fale com seus amigos  de graga com o novo Yahoo! Messenger
> http://br.messenger.yahoo.com/


Current Thread
Keywords