From: Joop R. <joo...@gm...> - 2009-04-29 07:46:24
|
Hello all, I need to be able to 'catch' xml content sent from a server as a string (I cannot influence what is sent. The xml I receive has a default namespace "http://www.re-phrase.com/klikpraat", but subelements "sentence" have mixed content with xhtml elements in them - however, these elements usually have no explicit namespace. eXist (correctly) puts them in the "http://www.re-phrase.com/klikpraat" namespace. So what I want to do is to manipulate the text of the content before it is interpreted as XML by eXist, that is, put the sentence explicitly in the "http://www.re-phrase.com/klikpraat" namespace and put a default xhtml namespace in it so the subelements will be in the correct namespace). I retrieve the content using the httpclient module. However, I cannot make it so that the received content is a string - it is always an element. I use version 1.2.5. The documentation says: "XML body content will be returned as a Node, HTML body content will be tidied into an XML compatible form, a body with mime-type of "text/..." will be returned as a URLEncoded string, and any other body content will be returned as xs:base64Binary encoded data." Here is the response (truncated in the content): Status=OK - 200 Date=Wed, 29 Apr 2009 07:27:49 GMT Server=Jetty/5.1.12 (Linux/2.6.24-23-generic i386 java/1.6.0_0 X-XQuery-Cached=true Expires=Thu, 01 Jan 1970 00:00:00 GMT Content-Type=text/plain; charset=UTF-8 Content-Length=5771 Set-Cookie=JSESSIONID=1e09pn02y7k6k;Path=/exist Keep-Alive=timeout=15, max=100 Connection=Keep-Alive <rp:phrases xmlns="http://www.re-phrase.com/klikpraat" xmlns:rp="http://www.re-phrase.com/klikpraat" source="main" author="Joop" dateTime="2009-03-26T21:54:12.984+01:00" nextPhraseIndex="50" displayName="adminHelp" product="autoAnswer" defaultLanguage="en" languages="en" auto_res="andere tevree" open_text_response="" rol1="support" rol2="client" top_phrase="id1" onStartConversation="autoAnswer" afterGetOptions="autoAnswer" deviceType="options-below" stylesheet="adminHelp"> <phrase id="id1" role="support" source="main"> <sentence language="nl">Waar wilt u iets over vragen?</sentence> <sentence language="en">What do you want to ask about?</sentence> <re id="id2"/> <re id="id3"/> <re id="id4"/> <re id="id5"/> <re id="id6"/> <re id="id7"/> <re id="id8"/> <re id="id9"/> </phrase> ... And here is the httpclient:response element (truncated at the same point): <httpclient:response xmlns:httpclient="http://exist-db.org/xquery/httpclient" statusCode="200"> <httpclient:headers> <httpclient:header name="Date" value="Wed, 29 Apr 2009 06:31:21 GMT"/> <httpclient:header name="Server" value="Jetty/5.1.12 (Linux/2.6.24-23-generic i386 java/1.6.0_0"/> <httpclient:header name="X-XQuery-Cached" value="true"/> <httpclient:header name="Expires" value="Thu, 01 Jan 1970 00:00:00 GMT"/> <httpclient:header name="Content-Type" value="text/plain; charset=UTF-8"/> <httpclient:header name="Content-Length" value="5771"/> <httpclient:header name="Set-Cookie" value="JSESSIONID=99u507st3y53;Path=/exist"/> </httpclient:headers> <httpclient:body mimetype="text/plain; charset=UTF-8" type="xml"> <rp:phrases xmlns:rp="http://www.re-phrase.com/klikpraat" source="main" author="Joop" dateTime="2009-03-26T21:54:12.984+01:00" nextPhraseIndex="50" displayName="adminHelp" product="autoAnswer" defaultLanguage="en" languages="en" auto_res="andere tevree" open_text_response="" rol1="support" rol2="client" top_phrase="id1" onStartConversation="autoAnswer" afterGetOptions="autoAnswer" deviceType="options-below" stylesheet="adminHelp"> <rp:phrase id="id1" role="support" source="main"> <rp:sentence language="nl">Waar wilt u iets over vragen?</rp:sentence> <rp:sentence language="en">What do you want to ask about?</rp:sentence> <rp:re id="id2"/> <rp:re id="id3"/> <rp:re id="id4"/> <rp:re id="id5"/> <rp:re id="id6"/> <rp:re id="id7"/> <rp:re id="id8"/> <rp:re id="id9"/> </rp:phrase> ... Why is the type attribute of the httpclient:body equal to "xml"? I guess I need it to be "text", so how can I achieve that? Or what am I doing wrong? Joop Ringelberg |