You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Vaduvoiu Tiberiu <va...@yahoo.com> on 2007/07/20 09:10:20 UTC
cocoon and ajax url path
Hi, I'm trying to use a ajax function to load an xml...the function is one that is frequently used/presented in ajax tutorials:
function loadXMLDoc(url)
{
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send(null);
// branch for IE/Windows ActiveX version
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send();
}
}
}
this pretty much works on static sites in html but as I am using cocoon, I am having problem giving the url of the xml...
in xslt i am using something like this to load an xml or to display a certain value from an xml:
document(concat('cocoon:/','preview','/',folder1/folder2/,file.xml))/root/node
but in ajax if try calling loadXMLDoc(cocoon:/preview/folder1/folder2/file.xml) surely enough it doesn't work. So has anyone had similar problem and found any solution? 10x
____________________________________________________________________________________
Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: cocoon and ajax url path
Posted by Grzegorz Kossakowski <gk...@apache.org>.
Steven D. Majewski pisze:
>
> 'cocoon:' is a pseudo-protocol ( as are some others like resource: &
> zip: ) -- it is only
> known internal to cocoon. Your browser knows how to http: or ftp: but it
> doesn't know how
> to cocoon: ( and AJAX is client side javascript. )
>
> You can use the request input module to get scheme, serverName,
> serverPort and contextPath
> to build a base url in the sitemap and pass it as a parameter to be used
> as a prefix to the URLs
> in place of the 'cocoon:' .
>
> See:
> http://localhost:8080/cocoon/samples/modules/request.html
> http://cocoon.apache.org/2.1/userdocs/concepts/modules.html
Hello Steven and Vaduvoiu.
Your solution is right but hey, wouldn't you like to let Cocoon do this dirty job of constructing proper url? Service-servlet framework
functionality gives you necessary tools to ask Cocoon exactly for this. See http://cocoon.zones.apache.org/daisy/cdocs-forms/g1/1351.html in
order to get idea how it works and simplifies things.
Ok, now you can be pretty sure that my e-mail is just plain advertisement for Cocoon 2.2 features but I couldn't resist... :-)
--
Grzegorz Kossakowski
http://reflectingonthevicissitudes.wordpress.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: cocoon and ajax url path
Posted by "Steven D. Majewski" <sd...@virginia.edu>.
On Jul 20, 2007, at 3:10 AM, Vaduvoiu Tiberiu wrote:
>
> this pretty much works on static sites in html but as I am using
> cocoon, I am having problem giving the url of the xml...
> in xslt i am using something like this to load an xml or to display
> a certain value from an xml:
>
> document(concat('cocoon:/','preview','/',folder1/
> folder2/,file.xml))/root/node
>
> but in ajax if try calling loadXMLDoc(cocoon:/preview/folder1/
> folder2/file.xml) surely enough it doesn't work. So has anyone had
> similar problem and found any solution? 10x
>
'cocoon:' is a pseudo-protocol ( as are some others like resource: &
zip: ) -- it is only
known internal to cocoon. Your browser knows how to http: or ftp: but
it doesn't know how
to cocoon: ( and AJAX is client side javascript. )
You can use the request input module to get scheme, serverName,
serverPort and contextPath
to build a base url in the sitemap and pass it as a parameter to be
used as a prefix to the URLs
in place of the 'cocoon:' .
See:
http://localhost:8080/cocoon/samples/modules/request.html
http://cocoon.apache.org/2.1/userdocs/concepts/modules.html
-- Steve Majewski
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org