You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Derek Hohls <DH...@csir.co.za> on 2004/06/03 09:50:43 UTC

Re: Is this good practice? [Was - Re: Newbie: How to capture XML from custom class? ]

Bertrand

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

Thanks
Derek

>>> bdelacretaz@apache.org 2004/06/03 09:02:31 AM >>>
Le 3 juin 04, à 08:12, Adam Walsh a écrit :
> ... in my case I did try using flow, but ran into a wall using  
> JXTemplate to spit out the XML from my Java object:
>
> http://marc.theaimsgroup.com/?l=xml-cocoon- 
> users&m=108415092708767&w=2...

If you have an XML *string* that you want JXTemplate to output as XML,  
you need to parse the string and convert it to a DOM Document object.

You can use the Cocoon parser component from Flow to build a DOM, and  
pass it to JX in the sendPage arguments.

>  If anyone has any ideas on how I can get around the escaping of the <  
> and > then I would glady ditch the XSP :)

Happy ditching ;-)

-Bertrand


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



-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.


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


Re: Is this good practice? [Was - Re: Newbie: How to capture XML from custom class? ]

Posted by Bertrand Delacretaz <bd...@apache.org>.
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