2006-06-19

Cocoon URIs

To give you flexibility in where you place resources that you might need in Cocoon, Cocoon adds some URL schemes to the commonly available ones:

  • http://hostname:port/resource—This is a standard HTTP URL. A sample URL is http://localhost:8080/myxml.xml.

  • context://servlet-context-path/resource—This scheme allows you to retrieve a resource relative to the servlet context on the current servlet engine. The URL context:///stylesheets/format.xsl refers to a resource stylesheets/format.xsl, relative to the current servlet context.

  • cocoon:/resource—This scheme allows you to refer to a resource produced by the current Cocoon sitemap. The URL cocoon:/mydata.xml passes the string mydata.xml to the current sitemap as the request URI. The current sitemap then processes that URI to obtain a resource that is returned.

  • cocoon://resource—This scheme is like the previous scheme except it uses the root sitemap for the Web application; this is indicated by two slashes (//) instead of one. For the URL cocoon://mydata.xml, Cocoon passes mydata.xml as the request URI to the root sitemap. The root sitemap processes the URI and returns a resource. Note that you can use this to access any sub-sitemaps because a sub-sitemap handles a subspace of the URI space.

  • resource://class-path-context/resource—This scheme allows you to obtain resources relative to the class loader for the current context. The class-path-context must be a path through the classpath to the data; when you’ve stored XML files side by side with the class files, this is the URI scheme you want to use. An example of this kind of URL is resource://org/apache/cocoon /components/language/markup/xsp/java/xsp.xsl.

  • jar://http://hostname:port/resource.jar!/path/in/jar—This scheme allows you to obtain resources that are contained in a Jar file. You need to specify the URI to the Jar file and the path inside the jar that leads to the resource. These two components are separated by an exclamation point (!).

  • file:///resource—This is a standard file URL. An example is file:///mydata.xml.


You can use these additional schemes anywhere a URI is called for.

没有评论:

发表评论