Re: sending xml response from servlet

Ok, I think I understand it. Using ISO-8859-1, I have to worry about:
- putting the corresponding HTTP response header to ISO-8859-1 encoding
- telling the serializer of the API that must use the encoding ISO-8859-1
- writing the characters in the document following the ISO-8859-1 (and the
starting XML definition = <?xml version="1.0" encoding="ISO-8859-1"?>)

Thanks for this information.

Returning to my previous problems, outputting data was already solved, but I
have been having troubles with the XML document treatment (i.e. setting data
in elements, I am incapable to find some method similar to this:
setElementValue(String elementName, String elementValue)).

So I will finally use the JAXB
API<http://java.sun.com/developer/technicalArticles/WebServices/jaxb/>.
I have been reading about it and I think that it is what I need. I have XML
Schemas that define my XML documents, and it seems easy to treat the entire
XML document with its binding capabilities. And I do not think that working
with other APIs (as Xindice) using JAXB is going to be more difficult that
with other APIs.

Greetings,
Iņaki


2007/2/20, Klotz, Leigh <Leigh.Klotz@xerox.com>:
>
>  Iņaki,
> Whatever API you use, when you serialize, you will need to tell the
> serializer what encoding to use, and specify that same value as the charset
> in the HTTP response header.
> ISO-8859-1 will work, but you must tell JDOM to use it; otherwise it will
> likely default to something else.
> XML that starts wtih <?xml version="1.0" ?> is UTF-8 by definition and so
> is the default.
> So you really have 3 places to worry about but the XML API you use will
> handle two of them (the XML declaration and the actual characters
> themselves).
> You must make sure that the HTTP response header has the right value in
> it.
> If this isn't clear, please ask me.
> Leigh.
>
>  ------------------------------
> *From:* www-forms-request@w3.org [mailto:www-forms-request@w3.org] *On
> Behalf Of *Iņaki Salinas Bueno
> *Sent:* Monday, February 19, 2007 12:25 PM
> *To:* www-forms
> *Subject:* Re: sending xml response from servlet
>
> Thanks all.
>
> I did so many things and I had to change the code so many times trying
> different forms to implement my application that I do not know which code I
> have used. But I am very happy with the help you gave to me.
>
> I tried to do it with JDOM library and I embroiled with it. I know why I
> embroiled now (ignorance of how to use the Java language), I will try it
> again later maybe.
>
> Referring to the last comment of Leigh, I suppose that charset=ISO-8859-1
> works too. And thanks for your comments about improving efficiency. It is
> not relevant for what I have to do but I will consider it if efficiency
> turns relevant.
>
> Regards,
> Iņaki
>
>
>
> 2007/2/19, Erik Bruchez <ebruchez@orbeon.com>:
> >
> >
> > Iņaki,
> >
> > We have a very simple example in JSP in our CVS (scroll past the
> > tags...):
> >
> >
> > http://cvs.forge.objectweb.org/cgi-bin/viewcvs.cgi/ops/orbeon/src/examples-jsp/flickr-search/service-search.jsp?rev=1.1&content-type=text/vnd.viewcvs-markup
> >
> > This example uses dom4j to read the submitted XML.
> >
> > BTW, I recommend you look at the eXist database instead of Xindice. This
> > will also allow you to have your forms directly talk with the database
> > using REST, instead of using a Java layer in the middle:
> >
> >    http://exist.sourceforge.net/
> >
> > We have examples on our web site on how to access eXist from XForms,
> > including in our tutorial:
> >
> >    http://www.orbeon.com/ops/doc/intro-tutorial
> >    http://www.orbeon.com/ops/xforms-bookcast/
> >
> > Our Government Forms example also uses REST to directly talk to eXist:
> >
> >    http://www.orbeon.com/ops/forms/
> >
> > I hope this helps,
> >
> > -Erik
> >
> > Iņaki Salinas Bueno wrote:
> > > Hello,
> > >
> > > Can someone recommend me a set of libraries that allow a servlet
> > > receive/send XML documents from/to xforms? I have found several
> > > libraries, but I don't know which is more adapted for what I want to
> > do.
> > >
> > > I'm using xforms in client side and a servlet for xindice (DB manager)
> >
> > > calls in server side.
> > >
> > > The servlet gets the xml document from xforms and add it in the DB
> > > correctly (I used a Xindice web application example and the tip
> > 'Xforms
> > > tip: Accepting XForms data in Java
> > > <
> > http://www-128.ibm.com/developerworks/java/library/x-xformstipjava/index.html
> > >'
> > > for its construction), but I don't know how can I get a XML document
> > > from DB and put it in the response object of the servlet.
> > >
> > > The example of the tip works with strings, so following it for the
> > > response I would have to take the XML document of the DB, transform it
> >
> > > into a string, and then send it. Cannot be the XML document sent as
> > > application/xml without transforming it into a string?
> > >
> > > Maybe questions are more java related than xforms, but they are
> > > working-with-xml related so I think that I can found help in this
> > forum.
> > >
> > > Thanks
> > > Iņaki
> >
> >
> > --
> > Orbeon Forms - Web Forms for the Enterprise Done the Right Way
> > http://www.orbeon.com/
> >
> >
>

Received on Tuesday, 20 February 2007 19:45:39 UTC