You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Hunsberger, Peter" <Pe...@stjude.org> on 2002/07/18 19:53:27 UTC

return nodeset from action?

Is it possible to return a parameter containing a NodeSet from a Cocoon
action?  If I was running an Xalan based servlet I could call a transform
with a parameter that was in fact an org.apache.xpath.NodeSet.  I'd like to
do the equivalent in Cocoon.  If I just do this directly Cocoon appears to
wrap the results as a String before passing it on to the transformer?

In my action I use code like:

	            map.put( "msgs", (NodeSet)myobject.getMsgs() );

where the getMsgs method returns a nodeset of 1 or more nodes that I'd then
like to reference inside an XSLT.  When I reference the parameter in my XSLT
(using xsl:copy-of select="$msgs") I get 
	org.apache.xpath.NodeSet@90fd20 
indicating that the Nodeset has been converted to a String at some point
before I'm referencing it. The site map looks like:

    <map:act set="test">
            <map:generate src="templates/test.xml"/>
            <map:transform src="stylesheets/resolve.xsl">
               <map:parameter name="msgs" value="{msgs}"/>
            </map:transform>
            <map:serialize type="xml"/>
    </map:act>

I suspect the problem is passing the parameter back via the sitemap.
However, if I don't do this I don't see the parameter in the XSLT at all.
I'd guess there is some magic parameter that tells Cocoon to pass the
parameters from the action map back to the transform as parameters?  Testing
with:
               <map:parameter name="parameters" value="true"/>
or
               <map:parameter name="use-request-parameters" value="true"/>
as parameters to the map:transform did not give the desired results...
Looking at the source doesn't reveal any particular magic to handle this.
My action just extends abstract action, but I don't see any other action
that would yield any other results?

Failing this capability, how else does one return structured data from an
action to a XSLT? (We do not want to use XSP's for this particular set of
transformations...)

I'm running Cocoon 2.0.3 (thanks for the many fixes and improvements :-)
with Tomcat 4.0.4 / JBoss 2.4.4 and JDK 1.4

Peter Hunsberger

Phone: 901-495-5252
E-mail: Peter.Hunsberger@stjude.org


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

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


RE: return nodeset from action?

Posted by Vadim Gritsenko <va...@verizon.net>.
> From: Hunsberger, Peter [mailto:Peter.Hunsberger@stjude.org]
> 
> Is it possible to return a parameter containing a NodeSet from a
Cocoon
> action? 

Not via sitemap. Request or session attributes will do.


> If I was running an Xalan based servlet I could call a transform
> with a parameter that was in fact an org.apache.xpath.NodeSet.  I'd
like to
> do the equivalent in Cocoon.  If I just do this directly Cocoon
appears to
> wrap the results as a String before passing it on to the transformer?
> 
> In my action I use code like:
> 
> 	            map.put( "msgs", (NodeSet)myobject.getMsgs() );
> 
> where the getMsgs method returns a nodeset of 1 or more nodes that I'd
then
> like to reference inside an XSLT.  When I reference the parameter in
my XSLT
> (using xsl:copy-of select="$msgs") I get
> 	org.apache.xpath.NodeSet@90fd20
> indicating that the Nodeset has been converted to a String at some
point
> before I'm referencing it. The site map looks like:
> 
>     <map:act set="test">
>             <map:generate src="templates/test.xml"/>
>             <map:transform src="stylesheets/resolve.xsl">
>                <map:parameter name="msgs" value="{msgs}"/>
>             </map:transform>
>             <map:serialize type="xml"/>
>     </map:act>
> 
> I suspect the problem is passing the parameter back via the sitemap.

See http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9916


Vadim


> However, if I don't do this I don't see the parameter in the XSLT at
all.
> I'd guess there is some magic parameter that tells Cocoon to pass the
> parameters from the action map back to the transform as parameters?
Testing
> with:
>                <map:parameter name="parameters" value="true"/>
> or
>                <map:parameter name="use-request-parameters"
value="true"/>
> as parameters to the map:transform did not give the desired results...
> Looking at the source doesn't reveal any particular magic to handle
this.
> My action just extends abstract action, but I don't see any other
action
> that would yield any other results?
> 
> Failing this capability, how else does one return structured data from
an
> action to a XSLT? (We do not want to use XSP's for this particular set
of
> transformations...)
> 
> I'm running Cocoon 2.0.3 (thanks for the many fixes and improvements
:-)
> with Tomcat 4.0.4 / JBoss 2.4.4 and JDK 1.4
> 
> Peter Hunsberger
> 
> Phone: 901-495-5252
> E-mail: Peter.Hunsberger@stjude.org


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

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