cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cocoon User <coc...@eng.gr>
Subject RE: XMLHTTP and cocoon [baseurl ?]
Date Mon, 30 Sep 2002 22:29:35 GMT

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:cocoon@eng.gr]
> > Sent: lunedi 30 settembre 2002 11.21
> > To: cocoon-users@xml.apache.org
> > 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:     <cocoon-users-unsubscribe@xml.apache.org>
> > For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>
> >
> >
>
>
> ---------------------------------------------------------------------
> 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:     <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>
>
>


---------------------------------------------------------------------
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:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message