ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <lmead...@apache.org>
Subject Re: Return as XML
Date Wed, 11 Apr 2007 13:57:23 GMT
Another way to do this (that will be less code, but an added
dependency) is with a tool like xstream: http://xstream.codehaus.org/

If you search the archives, I know someone posted an example, and it
was pretty darn slick.

Larry


On 4/11/07, André Rodrigues Pena <andre.ufrj@gmail.com> wrote:
> Meindert, thanks for your reply.
>
> I'm gonna test your tips through the day, If I have questions I call you back.
>
> Cheers
>
> On 4/11/07, Meindert <meindert@pastelebusiness.com> wrote:
> >
> >
> >
> >
> > Yes;
> >
> > <select id="messageQueue" parameterClass="map" resultClass="xml"
> > xmlResultName="Message">
> >
> >
> >
> > And you probably want to have control on the rows returned so you might need
> > to add a rowhandler
> >
> >
> >
> > Call to query
> >
> > RowHandler rowHandler=new xmlRowHandler("mailQueue");
> >
> > queryWithRowHandler("messageQueue", myParam, rowHandler);
> > // go through the list
> >
> > Document doc = ((xmlRowHandler) rowHandler).getDomDocument();
> >
> > return doc.getRootElement();
> >
> >
> >
> > row handler
> >
> > /* Inner Classes */
> >
> >     public static class xmlRowHandler implements RowHandler{
> >
> >
> >
> >         private Document domDocument;
> >
> >
> >
> >         public xmlRowHandler(String xmlResultName){
> >
> >             domDocument = DocumentHelper.createDocument();
> >
> >             Element root = getDomDocument().addElement( xmlResultName );
> >
> >         }
> >
> >
> >
> >         public void handleRow(Object object){
> >
> >             try{
> >
> >                 Document xmlFragment = DocumentHelper.parseText((String)
> > object);
> >
> >                 Element xmlElement= xmlFragment.getRootElement();
> >
> >                 Element root =
> > getDomDocument().getRootElement();
> >
> >                 root.add(xmlElement);
> >
> >             }catch(DocumentException e){
> >
> >                 logger.error("Parsing failed;" + e.getMessage());
> >
> >             }
> >
> >
> >
> >         }
> >
> >
> >
> >         public Document getDomDocument() {
> >
> >             return domDocument;
> >
> >
> >         }
> >
> >     }
> >
> >
> >
> >
> >
> > -----Original Message-----
> >  From: André Rodrigues Pena [mailto:andre.ufrj@gmail.com]
> >  Sent: 10 April 2007 10:19 PM
> >  To: user-java@ibatis.apache.org
> >  Subject: Return as XML
> >
> >
> >
> > Hi all,
> >
> > I'm new on iBatis. Can I have the results from SELECT and STORED
> >
> > PROCEDURE to be in XML format?
> >
> >
> >
> > How do I do that? Thanks!
> >
> >
> >
> > --
> >
> > André Rodrigues Pena
> >
> >
> >
> > LOCUS
> >
> > www.locus.com.br
> >
> >
> >
> > Blog
> >
> > www.techbreak.org
>
>
> --
> André Rodrigues Pena
>
> LOCUS
> www.locus.com.br
>
> Blog
> www.techbreak.org
>

Mime
View raw message