cocoon-docs mailing list archives

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

http://cocoon.zones.apache.org/daisy/documentation/1488.html

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

Parts
=====

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>
    
    </body>
(1 equal lines skipped)


Long description
----------------
This part has been added.
Mime type: text/xml
File name: null
Size: 3772 bytes
Content:
<html>
<body>

<h3>Example</h3>

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

<ul>
<li>org.apache.cocoon.servletservice.sample.linkrewriter-content (mounted at:
/cocoon-servlet-service-components-sample/linkrewriter-content)</li>
<li>org.apache.cocoon.servletservice.sample.linkrewriter-style (mounted at:
/cocoon-servlet-service-components-sample/linkrewriter-style)</li>
</ul>

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

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

<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"
/&gt;</pre>

<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>

<h3>Configuration</h3>

<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
like:</p>

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

  class="org.apache.cocoon.servletservice.linkrewrite.ServletLinkrewriteTransformer"&gt;
  &lt;property name="inputModule" ref="org.apache.cocoon.components.modules.input.InputModule/servlet"
/&gt;
  &lt;property name="rewriteAttributes"&gt;
    &lt;util:set set-class="java.util.HashSet"&gt;
      &lt;value&gt;src&lt;/value&gt;
      &lt;value&gt;ref&lt;/value&gt;
      &lt;value&gt;href&lt;/value&gt;
    &lt;/util:set&gt;
  &lt;/property&gt;
  &lt;property name="rewriteServlets"&gt;
    &lt;util:set set-class="java.util.HashSet"&gt;
      &lt;value&gt;style&lt;/value&gt;
    &lt;/util:set&gt;
  &lt;/property&gt;
&lt;/bean&gt;</pre>

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

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

<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>

<ul>
<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>
</ul>

<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>

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

</body>
</html>


Mime
View raw message