cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [DAISY] Updated: ServletLinkrewriteTransformer
Date Sun, 17 Aug 2008 14:59:10 GMT
A document has been updated:

Document ID: 1488
Branch: main
Language: default
Name: ServletLinkrewriteTransformer (unchanged)
Document Type: Sitemap Component (unchanged)
Updated on: 8/17/08 2:59:00 PM
Updated by: Lukas Lang

A new version has been created, state: draft


Short description
This part has been updated.
Mime type: text/xml (unchanged)
File name:  (unchanged)
Size: 273 bytes (previous version: 278 bytes)
Content diff:
(2 equal lines skipped)
    <p>ServletLinkrewriteTransformer can be used as a sitemap component to rewrite
    links, <br/>
--- occuring in attributes of tags, which don't necessarily need to be HTML tags.
--- <br/>
+++ occuring in attributes of tags, which don't necessarily need to be HTML. <br/>
    As an example, links to style specific resources can be rewritten.</p>
(1 equal lines skipped)

Long description
This part has been added.
Mime type: text/xml
File name: null
Size: 3772 bytes


<p>In this example, we have two SitemapServlets defined as Spring beans:</p>

<li>org.apache.cocoon.servletservice.sample.linkrewriter-content (mounted at:
<li>org.apache.cocoon.servletservice.sample.linkrewriter-style (mounted at:

<p>Assume, a HTML document, available via the content servlet, contains style
specific information like an external cascading style sheet:</p>

    &lt;link rel="stylesheet" type="text/css" href="servlet:style:/skin.css" /&gt;
    &lt;h1&gt;This heading should occur red&lt;/h1&gt;
    &lt;p&gt;This is simple content&lt;/p&gt;

<p>This document can not be served as it is, as servlets are only available
internally. The <em>href </em>attribute of the <em>link </em>tag must
first be
resolved by the ServletLinkrewriteTransformer, as it referrs to a servlet URI.
The link points to the servlet <em>style</em>, providing the <em>skin.css</em>
file. Using the configuration provided at the bottom of the page, this link
would be rewritten into:</p>

<pre>&lt;link rel="stylesheet" type="text/css" href="/cocoon-servlet-service-components/linkrewriter-style/skin.css"

<p>By this, the resource is now available for clients. For more information,
including the full sources of this example, see the Cocoon Service Servlet
Components sample.</p>


<p>The transformer is configured, using Spring's dependency injection mechanism.
The XML tag attributes to be taken into account and the servlets to be rewritten
must be specified. The Spring configuration file for this example would look

<pre>&lt;bean name="org.apache.cocoon.transformation.Transformer/servletLinkRewriter"

  &lt;property name="inputModule" ref="org.apache.cocoon.components.modules.input.InputModule/servlet"
  &lt;property name="rewriteAttributes"&gt;
    &lt;util:set set-class="java.util.HashSet"&gt;
  &lt;property name="rewriteServlets"&gt;
    &lt;util:set set-class="java.util.HashSet"&gt;

<p>At least, the following configuration details must be provided:</p>

<li>an InputModule</li>
<li>one attribute being taken into account</li>
<li>one servlet name to be considered for rewriting</li>

<p>As the ServletLinkrewriteTransformer processes the attributes of XML
elements, the InputModule is asked to resolve the servlet URI, if all of the
following conditions hold:</p>

<li>the attribut is in the <em>rewriteAttributes </em>set</li>
<li>the value of the attribute is a servlet URI. e.g. <em>servlet:</em></li>
<li>referenced servlet is in the <em>rewriteServlets </em>set</li>

<h3>Additional information</h3>

<p>Please keep in mind, LinkrewriteTransformer is capable to rewrite transitive
links. It is a matter of the referenced servlet to resolve the specified
resource. Saying, the <em>style </em>servlet has an additional servlet
connection to an <em>endpoint </em>servlet and uses the following sitemap
(excerpt only):</p>

    &lt;map:match pattern="skin.css"&gt;
      &lt;map:read src="servlet:endpoint:/{0}"/&gt;


View raw message