cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bertrand Delacretaz <bdelacre...@apache.org>
Subject Re: Is this good practice? [Was - Re: Newbie: How to capture XML from custom class? ]
Date Thu, 03 Jun 2004 08:03:44 GMT

Le 3 juin 04, à 09:50, Derek Hohls a écrit :

> Bertrand
>
> Is there a concrete example in the Cocoon samples
> (or the Wiki)  that "fleshes out" this approach in a little
> more detail?

Maybe not, but here are some code excerpts:

   import org.apache.excalibur.xml.dom.DOMParser;
   import org.w3c.dom.Document;
   import org.xml.sax.InputSource;

     ServiceManager manager;
    (obtained via Serviceable or something)

     public Document stringToDOM(String input) throws Exception {
         Document result = null;
         DOMParser parser = null;
         try {
             parser = (DOMParser)manager.lookup(DOMParser.ROLE);
             result = parser.parseDocument(new InputSource(new 
StringReader(input)));
         } finally {
             manager.release(parser);
         }
         return result;
     }

You could also do it directly from Flowscript by using 
cocoon.createComponent to do the lookup.

-Bertrand


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message