- From: Erik Bruchez <ebruchez@orbeon.com>
- Date: Tue, 20 Feb 2007 22:00:20 +0100
- To: www-forms <www-forms@w3.org>
Leigh & all, A correction: if you use the media type application/xml, which is the recommended media type for XML, i.e. you produce the header: Content-Type: application/xml then you must not add an encoding (charset) to that, because charset is defined for text media types. XML is actually not a text format in the usual sense, because of the XML declaration which can contain the encoding (and the default to UTF-8 if you don't have an XML declaration or no encoding in the declaration). In short, this is what I recommend: o Use application/xml o If you want to specify an output encoding other than UTF-8, do it by setting the appropriate parameter on your XML serialization API. o Always use the API to serialize XML to a binary stream rather than a text stream. -Erik Klotz, Leigh wrote: > 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 <mailto: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 > <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/ > > -- Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/
Received on Tuesday, 20 February 2007 21:00:38 UTC