Hi,

Maybe rephrasing the problem makes it clearer:

I'm building an XSP page that calls a Java Helper class which gets the data
in a hierarchical form. What I'd like to know is: what's the best way of
delivering the result to the calling XSP page without having to traverse the
hierarchy twice.

Example:

class MyClass {
public WhichDataType getData() {
<....get data from data source ....>
        return result;
}

When I would serialize the result data it could look like this:
<TopElement>
        <ID>some id</ID>
        <element>
                <name>nameOfElement</name>
                <value>someValue</value>
        </element>
        <element>
                <name>anotherElement</name>
                <element>
                        <name>aSubElement</name>
                        <value>this Element's value</value>
                </element>
                <element>
                        <name>This could also be nested</name>
                        <value>just a simple value</value>
                </element>
        </element>
</TopElement>

The "xml" above is not the data I get from the data source, I have to
manipulate it to make it easier to process in Cocoon. If I do that I might
as well use a datatype that I don't have to manually parse again in XSP to
build the above structure using <xsp:element>?

Does anyone have ideas about the best way to handle this?

I've thought about putting everything in a long String, but I don't know how
to parse the String in XSP to the corresponding XML.

Bye, Helma

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, 18 December 2003 16:43
> To: [EMAIL PROTECTED]
> Subject: How to convert a hierarchical structure to xml in java?
> 
> 
> Hi,
> 
> I'm in the middle of building an XSP page that can retrieve 
> information from
> my CORBA-based server. I'm now writing a helper class in Java 
> that can take
> the output of the server and transform it into something I 
> can easily manage
> in the XSP page.
> However, I'm stuck. The results are in a hierarchical 
> structure based on
> Vector and String or String[]. I want to manipulate this 
> before returning it
> to the XSP page, but I don't want to traverse the structure for the
> manipulation and then once more in the XSP page to build the XML.
> 
> Can anyone help?
> 
> Bye, Helma
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to