You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by pa...@mc.duke.edu on 2001/03/16 23:42:14 UTC

RTREEFRAG problem

I'm getting the error "Can not convert #RTREEFRAG to a NodeList!" and I
cannot figure out what I'm doing wrong.  I've searched the archives of this
mailing list and found a similar situation, but I swear my code looks just
like the person recommended.  I've read all the XSL and XPath docs I can
find and I can't find anything that suggests I'm doing anything wrong.  I'm
using Cocoon 1.8.2.  Any help would be greatly appreciated.

Here's my XML:
<?xml version="1.0"?>

<?cocoon-process type="xslt"?>
<?xml-stylesheet type="text/xsl" href="simple.xsl"?>

<page>
        <junk>
                <one>1</one>
                <two>2</two>
        </junk>
        <morejunk>
                blah
        </morejunk>
</page>

And here's simple.xsl:
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0"
>

<xsl:variable name="stored-junk"/>

<xsl:template match="/page">
        <xsl:variable name="stored-junk" select="junk"/>
        <xsl:apply-templates select="morejunk"/>
</xsl:template>

<xsl:template match="morejunk">
        <html><h1>
                <xsl:value-of select="$stored-junk/one"/>
        </h1></html>
</xsl:template>

</xsl:stylesheet>


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: RTREEFRAG problem

Posted by "Piroumian, Konstantin" <KP...@flagship.ru>.
You are absolutely correct!
I feel that I have to refresh my XSLT knowledge :)

> On Mon, 19 Mar 2001 12:29:57 +0300, Piroumian, Konstantin wrote:
>
> Well, feel a little awkward to object, but:
>
> >Hi!
> >
> >>
> >> I'm getting the error "Can not convert #RTREEFRAG to a NodeList!" and I
> >> cannot figure out what I'm doing wrong.  I've searched the archives of
> >this
> >> mailing list and found a similar situation, but I swear my code looks
just
> >> like the person recommended.  I've read all the XSL and XPath docs I
can
> >> find and I can't find anything that suggests I'm doing anything wrong.
> >I'm
> >> using Cocoon 1.8.2.  Any help would be greatly appreciated.
> >>
> >> Here's my XML:
> >> <?xml version="1.0"?>
> >>
> >> <?cocoon-process type="xslt"?>
> >> <?xml-stylesheet type="text/xsl" href="simple.xsl"?>
> >>
> >> <page>
> >>         <junk>
> >>                 <one>1</one>
> >>                 <two>2</two>
> >>         </junk>
> >>         <morejunk>
> >>                 blah
> >>         </morejunk>
> >> </page>
> >>
> >> And here's simple.xsl:
> >> <xsl:stylesheet
> >>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> >>   version="1.0"
> >> >
> >>
> >> <xsl:variable name="stored-junk"/>
> >>
> >> <xsl:template match="/page">
> >>         <xsl:variable name="stored-junk" select="junk"/>
> >>         <xsl:apply-templates select="morejunk"/>
> >> </xsl:template>
> >>
> >> <xsl:template match="morejunk">
> >>         <html><h1>
> >>                 <xsl:value-of select="$stored-junk/one"/>
> >>         </h1></html>
> >> </xsl:template>
> >>
> >> </xsl:stylesheet>
> >
> >AFAIR, you cannot use variables in XPath expressions, except in
predicates.
> >e.g.:
> ><xsl:value-of select="$stored-junk/one"/> - will give a n error, but
>
> this will give an error if stored-link is of 'Result tree fragment type',
> as http://www.w3.org/TR/xslt#section-Result-Tree-Fragments sayes,
> "However, the operations permitted on a result tree fragment are a subset
of
>  those permitted on a node-set. 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. When a permitted operation is performed on a result tree
fragment,
> it is performed exactly as it would be on the equivalent node-set."
> You get 'Result tree fragment' type of a variable if you do
> <xsl:variable name="stored-junk"><a/>..</xsl:variable> -- that is
explicitly give
> tags isde xsl:variable
>
>
> but if stored-junk is of type node list, and this happens if you do
> <xsl:variable name="stored-junk" select="/page/a/b"/>
> (here "/page/a/b" is an XPath expression, it matches some elements in the
> source xml tree), then it is legal to do
> <xsl:value-of select="$stored-junk/one"/>
> Here's a working sample from our applications:
>
>   <xsl:variable name="type"
select="/page/alpha/zzzz[@name=$pk]/mmm[@name=$www]/iii"/>
>   ...
>       <xsl:variable name="group" select="$type/resource/@group"/>
> It works! (Of course, if this works in Xalan does not prove it is allowed
by the spces,
> but i beleive that the specs allow this)
>
> ><xsl:value-of select="one[name(..) = $stored-junk]"/> will work (I didn't
> >test it)
> >
> >Also, you are not allowed to specify a top-level variable.
>
> Again not true.
> http://www.w3.org/TR/xslt#variables
> gives us
> <!-- Category: top-level-element -->
> <!-- Category: instruction -->
> <xsl:variable
>   name = qname
>   select = expression>
>   <!-- Content: template -->
> </xsl:variable>
>
> note those category above: top-level-element. It means that we're allowed
> to have top-level variables
>
> >Use <xsl:param> for that.
>
> This is for a slightly different purpose: this is for parameters passed
from the
> outside, from the invoker of the stylesheet. For example in C1 you may
> access http request parameters in this manner.
>
>
>
> Best regards,
>    Tagunov Anthony
>
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: RTREEFRAG problem

Posted by Tagunov Anthony <at...@nnt.ru>.
On Mon, 19 Mar 2001 12:29:57 +0300, Piroumian, Konstantin wrote:

Well, feel a little awkward to object, but:

>Hi!
>
>>
>> I'm getting the error "Can not convert #RTREEFRAG to a NodeList!" and I
>> cannot figure out what I'm doing wrong.  I've searched the archives of
>this
>> mailing list and found a similar situation, but I swear my code looks just
>> like the person recommended.  I've read all the XSL and XPath docs I can
>> find and I can't find anything that suggests I'm doing anything wrong.
>I'm
>> using Cocoon 1.8.2.  Any help would be greatly appreciated.
>>
>> Here's my XML:
>> <?xml version="1.0"?>
>>
>> <?cocoon-process type="xslt"?>
>> <?xml-stylesheet type="text/xsl" href="simple.xsl"?>
>>
>> <page>
>>         <junk>
>>                 <one>1</one>
>>                 <two>2</two>
>>         </junk>
>>         <morejunk>
>>                 blah
>>         </morejunk>
>> </page>
>>
>> And here's simple.xsl:
>> <xsl:stylesheet
>>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>   version="1.0"
>> >
>>
>> <xsl:variable name="stored-junk"/>
>>
>> <xsl:template match="/page">
>>         <xsl:variable name="stored-junk" select="junk"/>
>>         <xsl:apply-templates select="morejunk"/>
>> </xsl:template>
>>
>> <xsl:template match="morejunk">
>>         <html><h1>
>>                 <xsl:value-of select="$stored-junk/one"/>
>>         </h1></html>
>> </xsl:template>
>>
>> </xsl:stylesheet>
>
>AFAIR, you cannot use variables in XPath expressions, except in predicates.
>e.g.:
><xsl:value-of select="$stored-junk/one"/> - will give a n error, but

this will give an error if stored-link is of 'Result tree fragment type',
as http://www.w3.org/TR/xslt#section-Result-Tree-Fragments sayes,
"However, the operations permitted on a result tree fragment are a subset of
 those permitted on a node-set. 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. When a permitted operation is performed on a result tree fragment, 
it is performed exactly as it would be on the equivalent node-set."
You get 'Result tree fragment' type of a variable if you do
<xsl:variable name="stored-junk"><a/>..</xsl:variable> -- that is explicitly give
tags isde xsl:variable


but if stored-junk is of type node list, and this happens if you do
<xsl:variable name="stored-junk" select="/page/a/b"/>
(here "/page/a/b" is an XPath expression, it matches some elements in the
source xml tree), then it is legal to do
<xsl:value-of select="$stored-junk/one"/>
Here's a working sample from our applications:

  <xsl:variable name="type" select="/page/alpha/zzzz[@name=$pk]/mmm[@name=$www]/iii"/>
  ...
      <xsl:variable name="group" select="$type/resource/@group"/>
It works! (Of course, if this works in Xalan does not prove it is allowed by the spces,
but i beleive that the specs allow this)

><xsl:value-of select="one[name(..) = $stored-junk]"/> will work (I didn't
>test it)
>
>Also, you are not allowed to specify a top-level variable. 

Again not true.
http://www.w3.org/TR/xslt#variables
gives us
<!-- Category: top-level-element -->
<!-- Category: instruction -->
<xsl:variable
  name = qname 
  select = expression>
  <!-- Content: template -->
</xsl:variable> 

note those category above: top-level-element. It means that we're allowed
to have top-level variables

>Use <xsl:param> for that.

This is for a slightly different purpose: this is for parameters passed from the
outside, from the invoker of the stylesheet. For example in C1 you may
access http request parameters in this manner.



Best regards, 
   Tagunov Anthony



---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: RTREEFRAG problem

Posted by "Piroumian, Konstantin" <KP...@flagship.ru>.
Hi!

>
> I'm getting the error "Can not convert #RTREEFRAG to a NodeList!" and I
> cannot figure out what I'm doing wrong.  I've searched the archives of
this
> mailing list and found a similar situation, but I swear my code looks just
> like the person recommended.  I've read all the XSL and XPath docs I can
> find and I can't find anything that suggests I'm doing anything wrong.
I'm
> using Cocoon 1.8.2.  Any help would be greatly appreciated.
>
> Here's my XML:
> <?xml version="1.0"?>
>
> <?cocoon-process type="xslt"?>
> <?xml-stylesheet type="text/xsl" href="simple.xsl"?>
>
> <page>
>         <junk>
>                 <one>1</one>
>                 <two>2</two>
>         </junk>
>         <morejunk>
>                 blah
>         </morejunk>
> </page>
>
> And here's simple.xsl:
> <xsl:stylesheet
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>   version="1.0"
> >
>
> <xsl:variable name="stored-junk"/>
>
> <xsl:template match="/page">
>         <xsl:variable name="stored-junk" select="junk"/>
>         <xsl:apply-templates select="morejunk"/>
> </xsl:template>
>
> <xsl:template match="morejunk">
>         <html><h1>
>                 <xsl:value-of select="$stored-junk/one"/>
>         </h1></html>
> </xsl:template>
>
> </xsl:stylesheet>

AFAIR, you cannot use variables in XPath expressions, except in predicates.
e.g.:
<xsl:value-of select="$stored-junk/one"/> - will give a n error, but
<xsl:value-of select="one[name(..) = $stored-junk]"/> will work (I didn't
test it)

Also, you are not allowed to specify a top-level variable. Use <xsl:param>
for that.

Please, let me know if this helps.


Regards,
    Konstantin Piroumian.



---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>