You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Matthew Cordes <mc...@maine.edu> on 2000/04/03 23:02:25 UTC

XSP and Method Return Types

Sorry for the abundance of questions, but XSP is very different/new to me
and the docs seem to leave out critical info.

Here is my question:  How do I return something in a method within my xsp 
xml file? For instance, imagine I have a method that returns an Array,
Hashtable, or Vector which i populated via JDBC ( but that is not
important at this moment ), How do I then transform this array into a
list in the final HTML output...

I want to go from: 

	String array[] = { "1", "2", "3", "4", "5" }

to this:

	<html>
	...
	1
	2
	3
	4
	5
	...
	</html>

I have a general understanding of xsl, you needn't explain that.  What I
don't grasp is how I turn the contents of my array into xml so that it
can be processed, with a for-each or the like.  Or would I make a templat
for this and what might that look like?

What if I had a two dimesional array?


Thanks in advance
-matt

Re: XSP and Method Return Types

Posted by Stefano Mazzocchi <st...@apache.org>.
Ulrich Mayring wrote:

> Sometimes cocoon is so easy that it hurts ;-)

And the "Cocoon Quote of the Year" winner is...

> Ulrich

Man, I love that :)

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------



Re: XSP and Method Return Types

Posted by Ulrich Mayring <ul...@denic.de>.
Matthew Cordes wrote:
> 

> I have a general understanding of xsl, you needn't explain that.  What I
> don't grasp is how I turn the contents of my array into xml so that it
> can be processed, with a for-each or the like.  Or would I make a templat
> for this and what might that look like?

Yes, a template. What you do is you construct XML elements in your XSP
page and in your XSL stylesheet you transform that generated XML to HTML
(or whatever). Here's an example assuming you have an Enumeration called
e in an XSP page:

while (e.hasMoreElements()) {
	myarray = (String[]) e.nextElement();
	<array>
	<field0><xsp:expr>myarray[0]</xsp:expr></field0>
	<field1><xsp:expr>myarray[1]</xsp:expr></field1>
	...
	</array>
	}

This creates an XML structure that you can transform easily in your XSL
stylesheet. Sometimes cocoon is so easy that it hurts ;-)

Ulrich

-- 
Ulrich Mayring
DENIC eG, Softwareentwicklung