cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kowalski <mkowal...@stewartsshops.com>
Subject Re: Building Nodes with Java
Date Thu, 22 Mar 2001 20:52:04 GMT
I use producers and jdom to build xml dynamically.  Here is a link to a tutorial
on producers.

http://www.xmlmag.com/upload/free/features/xml/2000/04fal00/kj0004/kj0004.asp

www.jdom.org  is where to find jdom.

Here is how I hook the jdom output back into the producer.  Any suggestions on a
better technique would be greatly appreciated.

//---- Some things you will need -----
 private XMLOutputter fmt = new XMLOutputter();
 private StringReader sr = null;
 private StringWriter sw = new StringWriter();

//---- Below is the relevant snippet of code after I have created the dynamic
bit of XML and placed it  a jdom Element
   Document doc = new Document(elm);

   doc.addContent(CocoonHelper.getXSLTPI());
   doc.addContent(CocoonHelper.getStyleSheetPI(stylesheet));

   fmt.output( doc, sw );

   return sw.toString();

// the above code is then used by the producer as follows

public java.io.Reader getStream(javax.servlet.http.HttpServletRequest request) {

      Inquiry inq = new Inquiry(request);
      return new StringReader(inq.getResultXML());

 }

An XML string is returned and processed be the producer.

I hope that helps.


Matthew Smith wrote:

>     I'm hoping someone can give me a starting point for building on to my
> result xml documents dynamicly.  I think that's what I want to say.  I
> noticed the brief bit of information on xml fragments.  I also saw that
> through xsp you have access to the result tree through the org.w3c classes.
> Which should I use?  I couldn't find the API for the org.w3c classes such as
> Document and Node after looking for quite a while.
>     I'd really appretiate any help anyone could give me.  Links to tutorials
> and documentation would be great.
>
> Thanks,
> Matt
>
> ---------------------------------------------------------------------
> 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: <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail: <cocoon-users-help@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: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message