You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Steve Millington <st...@sun.com> on 2003/01/13 18:10:52 UTC

NewBee - Dynamically created XML

Being a newbee to Cocoon, I am wondering if someone can help me with a 
quick strategy to solve the following problem.

I already have a Java program that can produce XML text.

For example, I have a java Bean that has a generate() method that 
returns a String that contains a valid XML fragment.

I would like to use this generate XML in a pipeline, but I can't figure 
it out. The method of attack I used was to use XSP and have an xsp page 
something like:

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsp:page language="java"
xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-request="http://apache.org/xsp/request/2.0">

<xsp:structure>
  <xsp:include>com.mystuff.MyBean</xsp:include>
</xsp:structure>

<page>
  <xsp:logic>
   MyBean mb = new MyBean();
   String theXML = mb.generate();
  </xsp:logic>
  <xsp:expr>theXML</xsp:expr>
</page>

</xsp:page>

This does not work as I had hoped. The 'theXML' data is not placed into 
the XML tag tree, but rather is used as CDATA inside my <page> tag.
Is there something cunning I can do to persuade xsp that the data should 
be used to generate XML tag structure, rather than it being textual data.

Or maybe I am barking up the wrong Tree. I would write some 
implementation of Generator, but that looked a bit too complex for my 
liking since it would probably require the coding of MyBean to produce 
some sore of parsed XML rather than the text.

Thanks for any help.

Steve



---------------------------------------------------------------------
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: NewBee - Dynamically created XML

Posted by Cocoon User <co...@eng.gr>.
use aggregation in site map

to create a final xml from some xml fragments

we have test many ways to solve a problem like this
from xsp (dynamic pages) to c or x include but we have a least descide
touse sitemap aggregation

stavros



On Mon, 13 Jan 2003, Steve Millington wrote:

> Being a newbee to Cocoon, I am wondering if someone can help me with a
> quick strategy to solve the following problem.
>
> I already have a Java program that can produce XML text.
>
> For example, I have a java Bean that has a generate() method that
> returns a String that contains a valid XML fragment.
>
> I would like to use this generate XML in a pipeline, but I can't figure
> it out. The method of attack I used was to use XSP and have an xsp page
> something like:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <xsp:page language="java"
> xmlns:xsp="http://apache.org/xsp"
> xmlns:xsp-request="http://apache.org/xsp/request/2.0">
>
> <xsp:structure>
>   <xsp:include>com.mystuff.MyBean</xsp:include>
> </xsp:structure>
>
> <page>
>   <xsp:logic>
>    MyBean mb = new MyBean();
>    String theXML = mb.generate();
>   </xsp:logic>
>   <xsp:expr>theXML</xsp:expr>
> </page>
>
> </xsp:page>
>
> This does not work as I had hoped. The 'theXML' data is not placed into
> the XML tag tree, but rather is used as CDATA inside my <page> tag.
> Is there something cunning I can do to persuade xsp that the data should
> be used to generate XML tag structure, rather than it being textual data.
>
> Or maybe I am barking up the wrong Tree. I would write some
> implementation of Generator, but that looked a bit too complex for my
> liking since it would probably require the coding of MyBean to produce
> some sore of parsed XML rather than the text.
>
> Thanks for any help.
>
> Steve
>
>
>
> ---------------------------------------------------------------------
> 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>
>
>


---------------------------------------------------------------------
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: NewBee - Dynamically created XML

Posted by Geoff Howard <co...@leverageweb.com>.
Check out the util logicsheet (documentation is poor - you'll have to look
at the source).  You'd find it at
http://cvs.apache.org/viewcvs.cgi/xml-cocoon2/src/java/org/apache/cocoon/com
ponents/language/markup/xsp/java/util.xsl?rev=1.7&content-type=text/vnd.view
cvs-markup

I think you'll want to do:
...
<page>
   <xsp:logic>
    MyBean mb = new MyBean();
    String theXML = mb.generate();
   </xsp:logic>
   <util:include-expr>
   <util:expr><xsp:expr>theXML</xsp:expr></util:expr>
   </util:include-expr>
</page>
...

Make sure to include the util namespace in the doc:
xmlns:util="http://apache.org/xsp/util/2.0"

HTH,
Geoff Howard

> -----Original Message-----
> From: Steve Millington [mailto:steve.millington@sun.com]
> Sent: Monday, January 13, 2003 12:11 PM
> To: cocoon-users@xml.apache.org
> Subject: NewBee - Dynamically created XML
>
>
> Being a newbee to Cocoon, I am wondering if someone can help me with a
> quick strategy to solve the following problem.
>
> I already have a Java program that can produce XML text.
>
> For example, I have a java Bean that has a generate() method that
> returns a String that contains a valid XML fragment.
>
> I would like to use this generate XML in a pipeline, but I can't figure
> it out. The method of attack I used was to use XSP and have an xsp page
> something like:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <xsp:page language="java"
> xmlns:xsp="http://apache.org/xsp"
> xmlns:xsp-request="http://apache.org/xsp/request/2.0">
>
> <xsp:structure>
>   <xsp:include>com.mystuff.MyBean</xsp:include>
> </xsp:structure>
>
> <page>
>   <xsp:logic>
>    MyBean mb = new MyBean();
>    String theXML = mb.generate();
>   </xsp:logic>
>   <xsp:expr>theXML</xsp:expr>
> </page>
>
> </xsp:page>
>
> This does not work as I had hoped. The 'theXML' data is not placed into
> the XML tag tree, but rather is used as CDATA inside my <page> tag.
> Is there something cunning I can do to persuade xsp that the data should
> be used to generate XML tag structure, rather than it being textual data.
>
> Or maybe I am barking up the wrong Tree. I would write some
> implementation of Generator, but that looked a bit too complex for my
> liking since it would probably require the coding of MyBean to produce
> some sore of parsed XML rather than the text.
>
> Thanks for any help.
>
> Steve
>
>
>
> ---------------------------------------------------------------------
> 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>
>
>
>


---------------------------------------------------------------------
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>