i have succesfull write a js that create an xmlobject and then post it
using xmlhttp

i have too succesfull post this xml stream to .php and java servlet .
server side i just echo this stream and return this echo to js


how can i modify sitemap to make cocoon ready to receive this stream and
send a
responce back to js.

thanks
stavros s. kounis




On Tue, 1 Oct 2002, Giuseppe Bonelli wrote:

> Kounis,
> you have to insert the js snippet in a function and attach the function to whatever 
>event you want. baseurl is a variable containing the url pointing to the <map:match 
>pattern="foo/bar"> in the cocoon sitemap.
>
> The data flow is as follow:
> 1. a browser event triggers the js function
> 2. the js function send the xml data to the cocoon sitemap
> 3. the cocoon sitemap process the xml file through a source write transformer
> 4. the cocoon map returns to the browser a status message (and eventually other 
>generated xml)
> 5. the js function exits
>
> Your mileage may vary, but the principle is this.
>
> --peppo
>
> > -----Original Message-----
> > From: Cocoon User [mailto:[EMAIL PROTECTED]]
> > Sent: martedi 1 ottobre 2002 0.30
> > To: [EMAIL PROTECTED]
> > Subject: RE: XMLHTTP and cocoon [baseurl ?]
> >
> >
> >
> > thanx for the answer
> >
> > but can u give me an axample how to call this cocoon patern
> >
> > what's the baseurl?
> >
> >
> >
> >
> > On Mon, 30 Sep 2002, Giuseppe Bonelli wrote:
> >
> > > Here are a few snippets i use to exchange xml data from a
> > client side js and cocoon2.
> > >
> > > My scenario is: the client browser save an xml file on the
> > server using the source write transformer.
> > >
> > > If you need to echo the file back to the browser, just
> > serialize it again, eventually after another transformation.
> > >
> > > Hope this helps
> > >
> > > --peppo
> > >
> > > The client side js snippet:
> > >
> > >                   {
> > >                   ...
> > >                   reqxml=the-xml-you-want-to-transfer-to-cocoon
> > >                   xmlhttp.open("POST", baseurl, false);
> > >                   xmlhttp.send(reqxml);
> > >                   var resxml=xmlhttp.responseXML;
> > >                   //alert(resxml.xml);
> > >                   if (!reqxml.documentElement) {
> > >                                   alert("could not
> > parse:\n\n"+xmlhttp.responseText);
> > >                                   return null;
> > >                   }
> > >
> > >     // C2 error handling
> > >   try {
> > >                                   //check the response status
> > >                                   var buf=resxml.documentElement;
> > >
> > //alert(buf.childNodes.item(0).getAttribute("result"));
> > >                                   if
> > (buf.childNodes.item(0).getAttribute("result") != "success") {
> > >                                           var errmsg =
> > resxml.documentElement.text;
> > >                                           if (!ignoreErrors)
> > alert("Non e stato possibile salvare sul server il file.\n\n Il
> > server ha risposto: "+errmsg);
> > >                                           return null;
> > >                                   }
> > >                                   else {
> > >                                           var
> > fname=resxml.documentElement.childNodes.item(0).getAttribute("src");
> > >                                           var
> > pos=fname.indexOf('xdocs/');
> > >
> > fname=fname.slice(pos+6,fname.length-18);
> > >                                           alert("Una nuova
> > versione del file '"+fname+".xml' e stata salvata con successo
> > sul server\n\nBuona continuazione!");
> > >                                   }
> > >                           } catch (e) {
> > >                                   if (!ignoreErrors)
> > alert("Server returned an error, but was not understood by the
> > editor.\n\n");
> > >                                   return null;
> > >                           }
> > > },
> > >
> > > in the sitemap:
> > >
> > >       <map:match pattern="save">
> > >         <map:generate type="stream"/>
> > >         <map:transform type="write-source"/>
> > >         <map:serialize type="xml"/>
> > >       </map:match>
> > >
> > > NB: the error handling is done on the basis of the xml
> > generated by the source write transformer used in the sitemap.
> > See the docs for details.
> > >
> > >
> > > > -----Original Message-----
> > > > From: Cocoon User [mailto:[EMAIL PROTECTED]]
> > > > Sent: lunedi 30 settembre 2002 11.21
> > > > To: [EMAIL PROTECTED]
> > > > Subject: XMLHTTP and cocoon
> > > >
> > > >
> > > > hi folks
> > > >
> > > > i have make an html form than post an XML file (object with
> > javascript)
> > > > using XMLHTTP
> > > >
> > > > is there any way in cocoon to receive this post an simple
> > echo this XML
> > > > object in browser?
> > > >
> > > > (if not cocoon a tomcat webapp)
> > > >
> > > > i want to find a very simple example to test if i can transport an XML
> > > > object from a client (IE6) to the server where a cocoon and tomcat are
> > > > installed
> > > >
> > > >
> > > > thnx
> > > >
> > > > Kounis Stavros
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > Please check that your question  has not already been answered in the
> > > > FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
> > > >
> > > > To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
> > > > For additional commands, e-mail:   <[EMAIL PROTECTED]>
> > > >
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > Please check that your question  has not already been answered in the
> > > FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
> > >
> > > To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
> > > For additional commands, e-mail:   <[EMAIL PROTECTED]>
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > Please check that your question  has not already been answered in the
> > FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
> >
> > To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
> > For additional commands, e-mail:   <[EMAIL PROTECTED]>
> >
> >
>
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
> For additional commands, e-mail:   <[EMAIL PROTECTED]>
>
>


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to