I am using textarea controls in my XFORM and I wanted to keep the carriage
return, spaces, etc. with my xml data serialized. While submitting the form, I have used cdata-section-elements attribute and also passed the element reference but still it is not working My .XHTML looks like this <?xml version="1.0" encoding="iso-8859-1"?> <xhtml:html xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <xhtml:head> <xhtml:title/> <xforms:model id="medwatchmodelid" > <xforms:instance id="medwatch" xmlns=""> <data> <textareafield1/> <groupone> <textareafield2/> </groupone> </data> </xforms:instance> <xforms:submission action="http://localhost:8080/myapp/XFormSave" indent="true" cdata-section-elements="textareafield1 textareafield2" id="save" method="post" ref="instance('medwatch')" replace="none" validate="false"/> <xforms:message ev:event="xforms-xforms-submit-done" level="modal">submitted!</xforms:message> <xforms:message ev:event="xforms-submit-error" level="modal">Can't submit!</xforms:message> </xforms:model> </xhtml:head> <xhtml:body> <font face="Verdana" size="2" ><b>Text Area 1</b> <br /> <xforms:textarea xmlns="" ref="instance('medwatch')/textareafield1" style="width:98%;height:250px"> <xforms:label /> </xforms:textarea> </font> <xforms:group ref="instance('medwatch')/groupone" appearance="full"> <font face="Verdana" size="2" ><b>Text Area 2</b> <br /> <xforms:textarea xmlns="" ref="textareafield2" style="width:98%;height:250px"> <xforms:label /> </xforms:textarea> </font> </xforms:group> <xforms:submit submission="save"> <xforms:label>Submit</xforms:label> </xforms:submit> </xhtml:body> </xhtml:html> XFormSave is a servlet and in my do post, I had the following lines of code to get the data of form submitted BufferedReader requestData = new BufferedReader(new InputStreamReader(request.getInputStream())); StringBuffer stringBuffer = new StringBuffer(); String line; try{ while ((line = requestData.readLine()) != null) { stringBuffer.append(line); } } catch (Exception e) { e.printStackTrace(); } and finally, I will get the xml file in my StringBuffer. But, I am not able to get data with CDATA sections. Pl. inform me what is wrong in my approach Regards Sabeer -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Administrator
|
Sabeer,
I ran your example locally, enter "a" two carriage returns and "b". In the body of the POST, I do see the two carriage returns as expected: Have you tried to look at the HTTP traffic in your case? Alex |
Hi Alex, Thanks for the reply. What should be done if I need the xml data from the xform submitted with CDATA sections. I would like to get the data like this <?xml version="1.0" encoding="UTF-8"?> <data xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms"> <textareafield1><![CDATA[a b]]></textareafield1> <groupone> <textareafield2><![CDATA[a b]]></textareafield2> </groupone> </data> I have already included cdata-section-elements in my submission In my Servlet, I am using the following code to retrieve the data BufferedReader requestData = new BufferedReader(new InputStreamReader(request.getInputStream())); StringBuffer stringBuffer = new StringBuffer(); String line; try{ while ((line = requestData.readLine()) != null) { stringBuffer.append(line); } } catch (Exception e) { e.printStackTrace(); } For my application requirements, I have to use the servlet to get the data Regards Sabeer -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Administrator
|
Sabeer,
You can't specify that you want a: <textareafield1> <![CDATA[a b]]></textareafield1> instead of a: <textareafield1>a b</textareafield1> Both represent the same XML info set, and it shouldn't matter which one the <xforms:submission> sends. The CDATA is more of convenience for humans to escape a block that shouldn't be interpreted as XML. Say if you put HTML inside an element but don't want the HTML tags to be interpreted as XML elements; without the CDATA you'd have to escape all the < into <. Alex |
Free forum by Nabble | Edit this page |