You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by il...@apache.org on 2011/03/12 14:55:07 UTC

svn commit: r1080935 - in /cocoon/cocoon3/trunk: cocoon-sample/src/main/resources/COB-INF/ cocoon-sample/src/main/resources/COB-INF/linkrewriting/ cocoon-sax/src/main/java/org/apache/cocoon/sax/component/ cocoon-sax/src/test/java/org/apache/cocoon/sax/...

Author: ilgrosso
Date: Sat Mar 12 13:55:07 2011
New Revision: 1080935

URL: http://svn.apache.org/viewvc?rev=1080935&view=rev
Log:
#COCOON3-56 resolve fixed

Added:
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/linkrewriting/   (with props)
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/linkrewriting/apache_home.html
    cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/LinkRewriterException.java
    cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/RegexpLinkRewriterTransformer.java
Modified:
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap
    cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/AbstractLinkRewriterTransformer.java
    cocoon/cocoon3/trunk/cocoon-sax/src/test/java/org/apache/cocoon/sax/component/LinkRewriterTransformerTest.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-component.xml

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/linkrewriting/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Mar 12 13:55:07 2011
@@ -0,0 +1 @@
+.apache_home.html.swp

Added: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/linkrewriting/apache_home.html
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/linkrewriting/apache_home.html?rev=1080935&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/linkrewriting/apache_home.html (added)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/linkrewriting/apache_home.html Sat Mar 12 13:55:07 2011
@@ -0,0 +1,254 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+               "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License. 
+-->
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+   <!--
+      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+            This file is generated from XML source: DO NOT EDIT!
+      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+   -->
+	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+	<link rel="stylesheet" href="./css/style.css" type="text/css" media="screen, projection"/>
+	<!--[if IE]><link rel="stylesheet" href="./style/ie.css" type="text/css" media="screen, projection"/><![endif]-->
+<link rel="alternate" title="announce@apache.org Archives" type="application/atom+xml" href="http://mail-archives.apache.org/mod_mbox/www-announce/?format=atom" />
+     <meta name="author" content="The Apache Software Foundation" /><meta name="email" content="apache.AT.apache.DOT.org" />
+    <title>Welcome! - The Apache Software Foundation</title>
+  
+ </head>
+ <body>
+ 	<div class="navigation">
+		<ul>
+			<li><a href="./foundation" title="About the Foundation">Foundation</a></li>
+			<li><a href="http://projects.apache.org" title="Apache Projects">Projects</a></li>
+			<li><a href="http://people.apache.org" title="Apache People">People</a></li>
+			<li><a href="./foundation/getinvolved.html" title="Get involved in Apache">Get Involved</a></li>
+			<li><a href="./foundation/sponsorship.html" title="Support the mission of Apache">Support Apache</a></li>			
+			<li class="dlink"><a href="./dyn/closer.cgi" title="Download Apache projects">Download</a></li>
+			<li><a href="http://blogs.apache.org/foundation/" title="Foundation Blog">ASF Blog</a></li>
+			<li><a href="http://blogs.apache.org" title="Project Blogs">Project Blogs</a></li>
+		</ul>
+	</div>
+	<div class="container">
+	<hr class="space col"/>
+	<div class="block">
+		<div class="column span-24">
+      <div id="header">
+                          <h1>The Apache Software Foundation<br />
+  <span class="alt"><small>Celebrating a Decade of Open Source Leadership.</small></span></h1><p class="blurb">The Apache Software Foundation provides support for the Apache community of open-source software projects.  The <a href="http://projects.apache.org/">Apache projects</a> are characterized by a collaborative, consensus based development process, an open and pragmatic software license, and a desire to create high quality software that leads the way in its field.</p><p class="highlight">We are more than a group of projects sharing a server, we are a <em>community</em> of developers and users.</p>
+               </div>
+      </div>
+	</div>
+	<hr/>
+	<div class="block">
+    		<div class="column span-15 first append-1">
+			<h3>
+                          Latest News
+              </h3>
+		</div>
+		<div class="column span-8 las search">
+    			<form action="http://www.google.com/search" method="get">
+		         <input value="*.apache.org" name="sitesearch" type="hidden"/>
+		         <input size="10" name="q" id="query" type="text"/>
+		         <input name="Search" value="Go" type="submit"/>
+	       </form>
+		</div>
+	</div>
+	<div class="block content">
+		<div class="column span-15 colborder">
+                            
+<div class="section-content">
+<p><em>If you would like to keep up with news and announcements from the foundation and all its projects, you can subscribe to the <a href="foundation/mailinglists.html#foundation-announce">Apache Announcements List</a> or you can visit <a href="https://blogs.apache.org/foundation/">our foundation blog</a></em>. Latest blog entries:</p>
+<p>
+<a href="https://blogs.apache.org/foundation/entry/the_apache_software_foundation_receives"> Oracle agrees to purchase the IP and all assets of The Apache Software Foundation for $1.5 Billion.</a>
+<br /><i>Posted at: 10:00 PM Apr 1, 2010</i></p>
+<p>
+<a href="https://blogs.apache.org/foundation/entry/the_apache_software_foundation_announces2">The Apache Software Foundation Announces the 15th Anniversary of the Apache HTTP Web Server</a>
+<br /><i>Posted at: 2:00 PM Feb 23, 2010</i></p>
+<p>
+<a href="https://blogs.apache.org/foundation/entry/the_apache_software_foundation_announces1">The Apache Software Foundation Announces Apache SpamAssassin Version 3.3.0</a>
+<br /><i>Posted at: 3:04 PM Jan 26, 2010</i></p>
+<p>
+<a href="https://blogs.apache.org/foundation/entry/the_apache_software_foundation_announces">The Apache Software Foundation Announces Apache Pivot as Top-Level Project</a>
+<br /><i>Posted at: 11:11 AM Jan 20, 2010</i></p>
+<p>
+<a href="https://blogs.apache.org/foundation/entry/the_apache_software_foundation_welcomes">The Apache Software Foundation Welcomes Facebook as its Newest Sponsor</a>
+<br /><i>Posted at: 6:00 PM Jan 12, 2010</i></p>
+<p>
+<a href="https://blogs.apache.org/foundation/entry/notice_apache_spamassassin_y2k10_rule">NOTICE: Apache SpamAssassin Y2K10 Rule Bug - Update Your Rules Now!</a>
+<br /><i>Posted at: 4:56 PM Jan 2, 2010</i></p>
+</div>
+         </div>
+    <div class="column span-8 last">
+      <div class="block">
+        <div class="nav column span-11">
+          <div>
+               <div class="menuheader"><a 
+href="http://projects.apache.org/">Apache Projects</a></div> 
+  <ul>
+          <li><a href="http://httpd.apache.org/" title="Apache Web Server (httpd)">HTTP Server</a></li> 
+          <li><a href="http://abdera.apache.org/" title="Atom Publishing Protocol Implementation">Abdera</a></li> 
+          <li><a href="http://activemq.apache.org/" title="Distributed Messaging System">ActiveMQ</a></li> 
+          <li><a href="http://ant.apache.org/" title="Java-based build tool">Ant</a></li> 
+          <li><a href="http://apr.apache.org/" title="Apache Portable Runtime libraries">APR</a></li> 
+          <li><a href="http://archiva.apache.org/" title="Build Artifact Repository Manager">Archiva</a></li> 
+          <li><a href="http://buildr.apache.org/" title="Simple and intuitive build system for Java applications">Buildr</a></li> 
+          <li><a href="http://camel.apache.org/" title="Spring based Integration Framework which implements the Enterprise Integration Patterns">Camel</a></li> 
+          <li><a href="http://cayenne.apache.org/" title="User-friendly Java ORM with Tools">Cayenne</a></li> 
+          <li><a href="http://click.apache.org/" title="User-friendly page and component oriented web framework">Click</a></li> 
+          <li><a href="http://cocoon.apache.org/" title="Web development framework: separation of concerns, component-based">Cocoon</a></li> 
+          <li><a href="http://commons.apache.org/" title="Reusable Java components">Commons</a></li> 
+          <li><a href="http://continuum.apache.org/" title="Continuous Integration and Build Server">Continuum</a></li> 
+          <li><a href="http://couchdb.apache.org/" title="RESTful document database">CouchDB</a></li> 
+          <li><a href="http://cxf.apache.org/" title="Service Framework">CXF</a></li> 
+          <li><a href="http://db.apache.org/" title="Database access">DB</a></li> 
+          <li><a href="http://directory.apache.org/" title="Apache Directory Server">Directory</a></li> 
+          <li><a href="http://excalibur.apache.org/" title="Embeddable software libraries related to component and service management access">Excalibur</a></li> 
+          <li><a href="http://felix.apache.org/" title="OSGi Framework and components.">Felix</a></li> 
+          <li><a href="http://forrest.apache.org/" title="Aggregated multi-channel documentation, separation of concerns">Forrest</a></li> 
+          <li><a href="http://geronimo.apache.org/" title="Java2, Enterprise Edition (J2EE) container">Geronimo</a></li> 
+          <li><a href="http://gump.apache.org/" title="Continuous integration of open source projects">Gump</a></li> 
+          <li><a href="http://hadoop.apache.org/" title="Distributed computing platform">Hadoop</a></li> 
+          <li><a href="http://harmony.apache.org/" title="Open source implementation of Java SE">Harmony</a></li> 
+          <li><a href="http://hc.apache.org/" title="Java toolset of low level HTTP components">HttpComponents</a></li> 
+          <li><a href="http://ibatis.apache.org/" title="SQL Data Mapper for Java and .NET">iBATIS</a></li> 
+          <li><a href="http://incubator.apache.org/" title="Shepherd for new projects">Incubator</a></li> 
+          <li><a href="http://jackrabbit.apache.org/" title="Content Repository for Java">Jackrabbit</a></li> 
+          <li><a href="http://jakarta.apache.org/" title="Server-side Java">Jakarta</a></li> 
+          <li><a href="http://james.apache.org/" title="Java Apache Mail Enterprise Server">James</a></li> 
+          <li><a href="http://labs.apache.org/" title="The Innovation Laboratories of the Apache Software Foundation">Labs</a></li> 
+          <li><a href="http://lenya.apache.org/" title="Content Management System">Lenya</a></li> 
+          <li><a href="http://logging.apache.org/" title="Cross-language logging services">Logging</a></li> 
+          <li><a href="http://lucene.apache.org/" title="Search engine library">Lucene</a></li> 
+          <li><a href="http://maven.apache.org/" title="Java project management and comprehension tools">Maven</a></li> 
+          <li><a href="http://mina.apache.org/" title="Multipurpose Infrastructure for Network Application">Mina</a></li> 
+          <li><a href="http://myfaces.apache.org/" title="JavaServer(tm) Faces implementation and components">MyFaces</a></li> 
+          <li><a href="http://ode.apache.org/" title="Orchestration Director Engine: Business Process Management (BPM), Process Orchestration and Workflow through service compositioni.">ODE</a></li> 
+          <li><a href="http://ofbiz.apache.org/" title="Open for Business: enterprise automation software">OFBiz</a></li> 
+          <li><a href="http://openejb.apache.org/" title="OpenEJB: a modular, configurable, and extendable EJB Container System and Server">OpenEJB</a></li> 
+          <li><a href="http://openjpa.apache.org/" title="OpenJPA: Object Relational Mapping for Java">OpenJPA</a></li> 
+          <li><a href="http://openwebbeans.apache.org/" title="OpenWebBeans: JSR-299 Context and Dependency Injection for Java EE Platform Implementation">OpenWebBeans</a></li> 
+          <li><a href="http://pdfbox.apache.org/" title="Java library for working with PDF documents">PDFBox</a></li> 
+          <li><a href="http://perl.apache.org/" title="Dynamic websites using Perl">Perl</a></li> 
+          <li><a href="http://pivot.apache.org/" title="Rich Internet applications in Java">Pivot</a></li> 
+          <li><a href="http://poi.apache.org/" title="Java API for OLE 2 Compound Documents">POI</a></li> 
+          <li><a href="http://portals.apache.org/" title="Portal technology">Portals</a></li> 
+          <li><a href="http://qpid.apache.org/" title="Multiple language implementation of the latest Advanced Message Queuing Protocol (AMQP)">Qpid</a></li> 
+          <li><a href="http://roller.apache.org/" title="Java blog server">Roller</a></li> 
+          <li><a href="http://santuario.apache.org/" title="XML Security in Java and C++">Santuario</a></li> 
+          <li><a href="http://servicemix.apache.org/" title="Enterprise Service Bus">ServiceMix</a></li> 
+          <li><a href="http://shindig.apache.org/" title="Opensocial Reference Implementation">Shindig</a></li> 
+          <li><a href="http://sling.apache.org/" title="Web Framework for JCR Content Repositories">Sling</a></li> 
+          <li><a href="http://spamassassin.apache.org/" title="Mail filter to identify spam">SpamAssassin</a></li> 
+          <li><a href="http://stdcxx.apache.org/" title="Apache C++ Standard Library">STDCXX</a></li> 
+          <li><a href="http://struts.apache.org/" title="Model 2 framework for building Java web applications">Struts</a></li> 
+          <li><a href="http://subversion.apache.org/" title="Version Control">Subversion</a></li> 
+          <li><a href="http://synapse.apache.org/" title="Enterprise Service Bus and Mediation Framework">Synapse</a></li> 
+          <li><a href="http://tapestry.apache.org/" title="Component-based Java Web Application Framework">Tapestry</a></li> 
+          <li><a href="http://tcl.apache.org/" title="Dynamic websites using TCL">TCL</a></li> 
+          <li><a href="http://tiles.apache.org/" title="A templating framework for web application user interfaces">Tiles</a></li> 
+          <li><a href="http://tomcat.apache.org/" title="A Java Servlet and JSP Container">Tomcat</a></li> 
+          <li><a href="http://turbine.apache.org/" title="A Java Servlet Web Application Framework and associated component library">Turbine</a></li> 
+          <li><a href="http://tuscany.apache.org/" title="An SCA based Service Composition Framework">Tuscany</a></li> 
+          <li><a href="http://velocity.apache.org/" title="A Java Templating Engine">Velocity</a></li> 
+          <li><a href="http://wicket.apache.org/" title="Component-based Java Web Application Framework.">Wicket</a></li> 
+          <li><a href="http://ws.apache.org/">Web Services</a></li> 
+          <li><a href="http://xalan.apache.org/" title="XSLT processors in Java and C++">Xalan</a></li> 
+          <li><a href="http://xerces.apache.org/" title="XML parsers in Java, C++ and Perl">Xerces</a></li> 
+          <li><a href="http://xml.apache.org/" title="XML solutions focused on the web">XML</a></li> 
+          <li><a href="http://xmlbeans.apache.org/" title="XML-Java binding tool">XMLBeans</a></li> 
+          <li><a href="http://xmlgraphics.apache.org/" title="Conversion from XML to graphical output">XML Graphics</a></li> 
+          <li><a href="http://attic.apache.org/" title="Inactive project repository">Attic</a></li> 
+      </ul>
+          </div>
+        </div>
+        <div class="nav column prepend-1 span-12 last">
+               <h6><a 
+href="/foundation/">Foundation</a></h6>
+  <ul>
+          <li><a href="/foundation/faq.html">FAQ</a></li> 
+          <li><a href="/licenses/">Licenses</a></li> 
+          <li><a href="/foundation/news.html">News</a></li> 
+          <li><a href="/press/">Press Inquiries</a></li> 
+          <li><a href="/foundation/records/">Public Records</a></li> 
+          <li><a href="/foundation/sponsorship.html">Sponsorship</a></li> 
+          <li><a href="/foundation/contributing.html">Donations</a></li> 
+          <li><a href="/foundation/buy_stuff.html">Buy Stuff</a></li> 
+          <li><a href="/foundation/thanks.html">Thanks</a></li> 
+          <li><a href="/foundation/contact.html">Contact</a></li> 
+      </ul>
+      <h6>Foundation Projects</h6>
+  <ul>
+          <li><a href="/foundation/conferences.html" title="Meetings of developers and users">Conferences</a></li> 
+          <li><a href="/dev/" title="ASF Infrastructure: Operations and howto documents for PMCs and contributors">Infrastructure</a></li> 
+          <li><a href="/jcp/" title="Apache and the Java Community Process">JCP</a></li> 
+          <li><a href="/legal/" title="Legal Affairs">Legal Affairs</a></li> 
+          <li><a href="/press/" title="Public Relations">Public Relations</a></li> 
+          <li><a href="/security/" title="Security">Security</a></li> 
+          <li><a href="/travel/" title="Travel Assistance">Travel Assistance</a></li> 
+      </ul>
+      <h6>How it works</h6>
+  <ul>
+          <li><a href="/foundation/how-it-works.html">Introduction</a></li> 
+          <li><a href="/foundation/how-it-works.html#meritocracy">Meritocracy</a></li> 
+          <li><a href="/foundation/how-it-works.html#structure">Structure</a></li> 
+          <li><a href="/foundation/how-it-works.html#roles">Roles</a></li> 
+          <li><a href="/foundation/how-it-works.html#management">Collaboration</a></li> 
+          <li><a href="/foundation/how-it-works.html#infrastructure">Infrastructure</a></li> 
+          <li><a href="/foundation/how-it-works.html#incubator">Incubator</a></li> 
+          <li><a href="/press/">Public Relations Committee</a></li> 
+          <li><a href="/foundation/how-it-works.html#other">Other entities</a></li> 
+          <li><a href="/foundation/glossary.html">Glossary</a></li> 
+          <li><a href="/foundation/voting.html">Voting</a></li> 
+      </ul>
+      <h6><a 
+href="/foundation/getinvolved.html">Get Involved</a></h6>
+  <ul>
+          <li><a href="/foundation/mailinglists.html">Mailing Lists</a></li> 
+          <li><a href="/dev/version-control.html">Version Control</a></li> 
+          <li><a href="/dev/">Developer Info</a></li> 
+      </ul>
+      <h6>Download</h6>
+  <ul>
+          <li><a href="/dyn/closer.cgi">from a mirror</a></li> 
+      </ul>
+      <h6>Community</h6>
+  <ul>
+          <li><a href="/memorials/">Memorials</a></li> 
+      </ul>
+      <h6>Related Sites</h6>
+  <ul>
+          <li><a href="http://apachecon.com/" title="Official Apache Conference">ApacheCon</a></li> 
+          <li><a href="http://feathercast.org/" title="Apache Podcasts">Feathercast</a></li> 
+          <li><a href="http://planet.apache.org/committers/" title="Apache Committers' Blogs">PlanetApache</a></li> 
+      </ul>
+        </div>
+      </div>
+    </div>
+    <div class="column span-24 footer">
+      <hr/>
+        <p>Copyright &#169; 2010 The Apache Software Foundation, Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.<br/>
+        Apache and the Apache feather logo are trademarks of The Apache Software Foundation.</p>
+      </div>
+    </div>
+  </div>
+</body>
+</html>
+

Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html?rev=1080935&r1=1080934&r2=1080935&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html Sat Mar 12 13:55:07 2011
@@ -94,6 +94,10 @@
     <li><a href="aggregation/include-transformer">Include-Transformer</a>: Aggregate XML using the IncludeTransformer.</li>
     <li><a href="aggregation/xinclude-transformer">XInclude-Transformer</a>: Aggregate XML using the XIncludeTransformer, working according to the <a href="http://www.w3.org/TR/xinclude/">XInclude specification</a>.</li>
   </ul>
+  <h2>Link rewriting</h2>
+  <ul>
+    <li><a href="linkrewriting/regexplinkrewriter-transformer">RegexpLinkRewriter-Transformer</a>: Aggregate XML using the IncludeTransformer.</li>
+  </ul>
   <h2>XSLT</h2>
   <ul>
     <li><a href="xslt/main">XSLT Transformation</a>: An XSLT transformation that includes stylesheets via file and servlet protocol.</li>

Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap?rev=1080935&r1=1080934&r2=1080935&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap Sat Mar 12 13:55:07 2011
@@ -364,6 +364,24 @@
       </map:match>
     </map:pipeline>
 
+    <!-- ~~~~~~~~~~~~~~~~ link rewriting ~~~~~~~~~~~~~~~ -->
+    <map:pipeline>
+      <map:match equals="linkrewriting/regexplinkrewriter-transformer">
+        <map:generate src="linkrewriting/apache_home.html" />
+        <map:transform type="regexplinkrewriter">
+            <map:parameter name="element1"
+                           value="a href"/>
+            <map:parameter name="element2"
+                           value="http://www.w3.org/1999/xhtml link * href"/>
+            <map:parameter name="regexp1"
+                           value="^\./([\.]*) http://www.apache.org/$1"/>
+            <map:parameter name="regexp2"
+                           value="^/([\.]*) http://www.apache.org/$1"/>
+        </map:transform>
+        <map:serialize type="xml" />
+      </map:match>
+    </map:pipeline>
+
     <!-- ~~~~~~~~~~~~~~~~ xslt ~~~~~~~~~~~~~~~ -->
     <map:pipeline>
       <map:match equals="xslt/main">

Modified: cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/AbstractLinkRewriterTransformer.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/AbstractLinkRewriterTransformer.java?rev=1080935&r1=1080934&r2=1080935&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/AbstractLinkRewriterTransformer.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/AbstractLinkRewriterTransformer.java Sat Mar 12 13:55:07 2011
@@ -22,7 +22,6 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
-
 import org.apache.cocoon.pipeline.caching.CacheKey;
 import org.apache.cocoon.pipeline.caching.SimpleCacheKey;
 import org.apache.cocoon.pipeline.component.CachingPipelineComponent;
@@ -33,54 +32,90 @@ import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.AttributesImpl;
 
-public abstract class AbstractLinkRewriterTransformer extends AbstractSAXTransformer implements CachingPipelineComponent {
+public abstract class AbstractLinkRewriterTransformer
+        extends AbstractSAXTransformer implements CachingPipelineComponent {
+
+    protected static final String ALL_NAMESPACES = "*";
+
+    protected static final String EMPTY_NAMESPACE = "";
 
-    public static final String ALL_NAMESPACES = "*";
+    private static final String ELEMENT_PREFIX = "element";
 
-    private static final String EMPTY_NAMESPACE = "";
+    protected static final Log LOG = LogFactory.getLog(
+            AbstractLinkRewriterTransformer.class);
+
+    private final Map<Element, Set<Element>> elements =
+            new HashMap<Element, Set<Element>>();
+
+    @Override
+    public void setConfiguration(
+            final Map<String, ? extends Object> configuration) {
 
-    private final Log log = LogFactory.getLog(this.getClass());
+        this.setup((Map<String, Object>) configuration);
+    }
 
-    private final Map<Element, Set<Element>> elements = new HashMap<Element, Set<Element>>();
+    @Override
+    public void setup(final Map<String, Object> parameters) {
+        if (parameters == null || parameters.isEmpty()) {
+            return;
+        }
+
+        String[] split;
+        for (Map.Entry<String, Object> parameter : parameters.entrySet()) {
+            if (parameter.getKey().startsWith(ELEMENT_PREFIX)) {
+                split = ((String) parameter.getValue()).split(" ");
+                if (split.length == 2) {
+                    this.addElement(split[0], split[1]);
+                } else if (split.length == 4) {
+                    this.addElement(split[0], split[1], split[2], split[3]);
+                } else {
+                    LOG.error("Invalid element as parameter, ignoring: "
+                            + parameter.getValue());
+                }
+            }
+        }
+    }
 
     @Override
-    public final void startElement(String uri, String localName, String name, Attributes atts)
+    public final void startElement(final String uri, final String localName,
+            final String name, Attributes atts)
             throws SAXException {
 
-        if (this.log.isDebugEnabled()) {
-            this.log.debug("Processing element (namespace="
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Processing element (namespace="
                     + uri
                     + ", name="
                     + localName
                     + ")");
         }
 
-        String attributeNamespace = null;
-        String attributeName = null;
-        String attributeValue = null;
+        String attributeNS;
+        String attributeName;
+        String attributeValue;
         for (int i = 0; i < atts.getLength(); i++) {
-            attributeNamespace = atts.getURI(i);
+            attributeNS = atts.getURI(i);
             attributeName = atts.getLocalName(i);
-            if (this.log.isDebugEnabled()) {
-                this.log.debug("Processing attribute ( namepsace="
-                        + attributeNamespace
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Processing attribute ( namepsace="
+                        + attributeNS
                         + ", name="
                         + attributeName
                         + ")");
             }
 
-            if (this.contains(uri, localName, attributeNamespace, attributeName)) {
-                if (this.log.isDebugEnabled()) {
-                    this.log.debug("Element has attributes to rewrite");
+            if (this.contains(uri, localName, attributeNS, attributeName)) {
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Element has attributes to rewrite");
                 }
 
                 attributeValue = atts.getValue(i);
                 atts = new AttributesImpl(atts);
                 try {
-                    String rewrite = this.rewrite(uri, name, attributeNamespace, attributeName, attributeValue);
+                    final String rewrite = this.rewrite(uri, name,
+                            attributeNS, attributeName, attributeValue);
                     ((AttributesImpl) atts).setValue(i, rewrite);
-                } catch (Exception e) {
-                    this.log.error("An error occurred while rewriting link '"
+                } catch (LinkRewriterException e) {
+                    LOG.error("An error occurred while rewriting link '"
                             + attributeValue
                             + "' ("
                             + name
@@ -91,8 +126,8 @@ public abstract class AbstractLinkRewrit
             }
         }
 
-        if (this.log.isDebugEnabled()) {
-            this.log.debug("Finished processing (namespace="
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Finished processing (namespace="
                     + uri
                     + ", name="
                     + localName
@@ -102,25 +137,30 @@ public abstract class AbstractLinkRewrit
         super.startElement(uri, localName, name, atts);
     }
 
-    public final void addElement(String elementName, String attributeName) {
-        this.addElement(ALL_NAMESPACES, elementName, ALL_NAMESPACES, attributeName);
+    public final void addElement(final String elementName,
+            final String attributeName) {
+
+        this.addElement(ALL_NAMESPACES, elementName, ALL_NAMESPACES,
+                attributeName);
     }
 
-    public final void addElement(String elementNamespace,
-            String elementName,
-            String attributeNamespace,
-            String attributeName) {
+    public final void addElement(final String elementNS,
+            final String elementName,
+            final String attributeNS,
+            final String attributeName) {
+
         if (elementName == null) {
-            throw new IllegalArgumentException("Parameter 'elementName' must not be null");
-        }
-        if (attributeName == null) {
-            throw new IllegalArgumentException("Parameter 'attributeName' must not be null");
+            throw new IllegalArgumentException(
+                    "Parameter 'elementName' must not be null");
         }
+        final Element key = new Element(
+                elementNS == null ? EMPTY_NAMESPACE : elementNS,
+                elementName);
 
-        if (elementNamespace == null) {
-            elementNamespace = EMPTY_NAMESPACE;
+        if (attributeName == null) {
+            throw new IllegalArgumentException(
+                    "Parameter 'attributeName' must not be null");
         }
-        Element key = new Element(elementNamespace, elementName);
 
         Set<Element> attributes;
         if (this.elements.containsKey(key)) {
@@ -130,29 +170,27 @@ public abstract class AbstractLinkRewrit
             this.elements.put(key, attributes);
         }
 
-        if (attributeNamespace == null) {
-            attributeNamespace = EMPTY_NAMESPACE;
-        }
-        attributes.add(new Element(attributeNamespace, attributeName));
+        attributes.add(new Element(
+                attributeNS == null ? EMPTY_NAMESPACE : attributeNS,
+                attributeName));
     }
 
-    protected abstract String rewrite(String elementNamespace,
+    protected abstract String rewrite(String elementNS,
             String elementName,
-            String atributeNamespace,
+            String attributeNS,
             String attributeName,
-            String link) throws Exception;
-
-    private boolean contains(String elementNamespace,
-            String elementName,
-            String atributeNamespace,
-            String attributeName) {
-        Element element = new Element(elementNamespace, elementName);
-        return this.elements.containsKey(element) &&
-                this.elements.get(element).contains(new Element(atributeNamespace, attributeName));
-    }
+            String link)
+            throws LinkRewriterException;
 
-    protected final Log getLog() {
-        return this.log;
+    private boolean contains(final String elementNamespace,
+            final String elementName,
+            final String atributeNamespace,
+            final String attributeName) {
+
+        final Element element = new Element(elementNamespace, elementName);
+        return this.elements.containsKey(element)
+                && this.elements.get(element).contains(new Element(
+                atributeNamespace, attributeName));
     }
 
     private final class Element {
@@ -161,7 +199,7 @@ public abstract class AbstractLinkRewrit
 
         private final String name;
 
-        public Element(String namespace, String name) {
+        public Element(final String namespace, final String name) {
             this.namespace = namespace;
             this.name = name;
         }
@@ -178,11 +216,12 @@ public abstract class AbstractLinkRewrit
         public int hashCode() {
             final int initialNonZeroOddNumber = 97;
             final int multiplierNonZeroOddNumber = 7;
-            return initialNonZeroOddNumber * multiplierNonZeroOddNumber + this.name.hashCode();
+            return initialNonZeroOddNumber * multiplierNonZeroOddNumber
+                    + this.name.hashCode();
         }
 
         @Override
-        public boolean equals(Object obj) {
+        public boolean equals(final Object obj) {
             if (this == obj) {
                 return true;
             }
@@ -191,11 +230,12 @@ public abstract class AbstractLinkRewrit
                 return false;
             }
 
-            Element other = (Element) obj;
+            final Element other = (Element) obj;
 
             if (!(ALL_NAMESPACES.equals(this.namespace)
                     || ALL_NAMESPACES.equals(other.getNamespace()))
                     && !this.namespace.equals(other.getNamespace())) {
+
                 return false;
             }
 
@@ -214,10 +254,9 @@ public abstract class AbstractLinkRewrit
                     + this.name
                     + "' }";
         }
-
     }
 
-    public CacheKey constructCacheKey() {
+    public final CacheKey constructCacheKey() {
         return new SimpleCacheKey();
     }
 }

Added: cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/LinkRewriterException.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/LinkRewriterException.java?rev=1080935&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/LinkRewriterException.java (added)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/LinkRewriterException.java Sat Mar 12 13:55:07 2011
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.sax.component;
+
+import org.apache.cocoon.pipeline.ProcessingException;
+
+public class LinkRewriterException extends ProcessingException {
+
+    public LinkRewriterException(final String message, final Throwable cause) {
+        super(message, cause);
+    }
+}

Added: cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/RegexpLinkRewriterTransformer.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/RegexpLinkRewriterTransformer.java?rev=1080935&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/RegexpLinkRewriterTransformer.java (added)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/RegexpLinkRewriterTransformer.java Sat Mar 12 13:55:07 2011
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cocoon.sax.component;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+public class RegexpLinkRewriterTransformer
+        extends AbstractLinkRewriterTransformer {
+
+    private static final String REGEXP_PREFIX = "regexp";
+
+    private final transient Map<Pattern, String> matchingMap =
+            new HashMap<Pattern, String>();
+
+    public RegexpLinkRewriterTransformer() {
+        super();
+    }
+
+    public RegexpLinkRewriterTransformer(
+            final Map<String, String> regexpMatch) {
+
+        super();
+
+        init(regexpMatch);
+    }
+
+    @Override
+    public void setup(final Map<String, Object> parameters) {
+        if (parameters == null || parameters.isEmpty()) {
+            return;
+        }
+
+        super.setup(parameters);
+
+        final Map<String, String> regexpMatch = new HashMap<String, String>();
+
+        String[] split;
+        for (Map.Entry<String, Object> parameter : parameters.entrySet()) {
+            if (parameter.getKey().startsWith(REGEXP_PREFIX)) {
+                split = ((String) parameter.getValue()).split(" ");
+                if (split.length == 2) {
+                    regexpMatch.put(split[0], split[1]);
+                } else {
+                    LOG.error("Invalid regexp as parameter, ignoring: "
+                            + parameter.getValue());
+                }
+            }
+        }
+
+        this.init(regexpMatch);
+    }
+
+    private void init(final Map<String, String> regexpMatch) {
+        if (regexpMatch != null && !regexpMatch.isEmpty()) {
+            for (Map.Entry<String, String> entry : regexpMatch.entrySet()) {
+                try {
+                    this.matchingMap.put(Pattern.compile(entry.getKey()),
+                            entry.getValue());
+                } catch (PatternSyntaxException e) {
+                    LOG.error("Could not compile regular expression '"
+                            + entry.getKey() + "'", e);
+                }
+            }
+        }
+    }
+
+    @Override
+    protected String rewrite(final String elementNS,
+            final String elementName,
+            final String attributeNS,
+            final String attributeName,
+            final String link)
+            throws LinkRewriterException {
+
+        String result = link;
+
+        Map.Entry<Pattern, String> entry;
+        Matcher matcher;
+        for (Iterator<Map.Entry<Pattern, String>> itor =
+                matchingMap.entrySet().iterator();
+                itor.hasNext() && result.equals(link);) {
+
+            entry = itor.next();
+            matcher = entry.getKey().matcher(link);
+            result = matcher.replaceAll(entry.getValue());
+        }
+        if (LOG.isDebugEnabled() && link.equals(result)) {
+            LOG.debug("No match found for '" + link + "'");
+        }
+
+        return result;
+    }
+}

Modified: cocoon/cocoon3/trunk/cocoon-sax/src/test/java/org/apache/cocoon/sax/component/LinkRewriterTransformerTest.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/test/java/org/apache/cocoon/sax/component/LinkRewriterTransformerTest.java?rev=1080935&r1=1080934&r2=1080935&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/test/java/org/apache/cocoon/sax/component/LinkRewriterTransformerTest.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/test/java/org/apache/cocoon/sax/component/LinkRewriterTransformerTest.java Sat Mar 12 13:55:07 2011
@@ -22,6 +22,8 @@ import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStreamReader;
 import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
@@ -30,6 +32,8 @@ import javax.xml.parsers.SAXParserFactor
 import org.apache.cocoon.pipeline.NonCachingPipeline;
 import org.apache.cocoon.pipeline.Pipeline;
 import org.apache.cocoon.sax.SAXPipelineComponent;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.custommonkey.xmlunit.Diff;
 import org.custommonkey.xmlunit.XMLUnit;
 import org.junit.BeforeClass;
@@ -37,48 +41,59 @@ import org.junit.Test;
 
 public final class LinkRewriterTransformerTest {
 
+    private static final Log LOG = LogFactory.getLog(
+            LinkRewriterTransformerTest.class);
+
     @BeforeClass
     public static void setUp() {
         XMLUnit.setIgnoreWhitespace(true);
         XMLUnit.setIgnoreComments(true);
         XMLUnit.setIgnoreAttributeOrder(true);
 
-        SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
-        saxParserFactory.setValidating(false);
+        final SAXParserFactory saxPFactory = SAXParserFactory.newInstance();
+        saxPFactory.setValidating(false);
         try {
-            saxParserFactory.setFeature(
-                    "http://apache.org/xml/features/nonvalidating/load-external-dtd",
+            saxPFactory.setFeature(
+                    "http://apache.org/xml/features/"
+                    + "nonvalidating/load-external-dtd",
                     false);
         } catch (Exception e) {
-            e.printStackTrace();
+            LOG.error("While setting up SAX parser factory", e);
         }
-        XMLUnit.setSAXParserFactory(saxParserFactory);
+        XMLUnit.setSAXParserFactory(saxPFactory);
 
-        DocumentBuilderFactory documentBuilderfactory =
+        final DocumentBuilderFactory docBuildFactory =
                 DocumentBuilderFactory.newInstance();
-        documentBuilderfactory.setNamespaceAware(true);
-        documentBuilderfactory.setValidating(false);
+        docBuildFactory.setNamespaceAware(true);
+        docBuildFactory.setValidating(false);
         try {
-            documentBuilderfactory.setFeature(
-                    "http://apache.org/xml/features/nonvalidating/load-external-dtd",
+            docBuildFactory.setFeature(
+                    "http://apache.org/xml/features/"
+                    + "nonvalidating/load-external-dtd",
                     false);
         } catch (ParserConfigurationException e) {
+            LOG.error("While setting up Document builder factory", e);
         }
-        XMLUnit.setControlDocumentBuilderFactory(documentBuilderfactory);
-        XMLUnit.setTestDocumentBuilderFactory(documentBuilderfactory);
+        XMLUnit.setControlDocumentBuilderFactory(docBuildFactory);
+        XMLUnit.setTestDocumentBuilderFactory(docBuildFactory);
     }
 
     /**
      * Test that all non-absolute HTTP links are rewritten as absolute links.
+     * @throws Exception if anything goes wrong
      */
     @Test
-    public void testXhtmlLinkRewriting() throws Exception {
-        URL source = this.getClass().getResource("/apache_home.html");
+    public void testXhtmlLinkRewriting()
+            throws Exception {
+
+        final URL source = this.getClass().getResource("/apache_home.html");
 
-        Pipeline<SAXPipelineComponent> pipeline = new NonCachingPipeline<SAXPipelineComponent>();
+        final Pipeline<SAXPipelineComponent> pipeline =
+                new NonCachingPipeline<SAXPipelineComponent>();
         pipeline.addComponent(new XMLGenerator(source));
 
-        AbstractLinkRewriterTransformer lrt = new AbsoluteLinkRewriterTransformer();
+        final AbstractLinkRewriterTransformer lrt =
+                new AbsoluteLinkRewriterTransformer();
         lrt.addElement("a", "href");
         lrt.addElement("http://www.w3.org/1999/xhtml",
                 "link",
@@ -88,57 +103,117 @@ public final class LinkRewriterTransform
 
         pipeline.addComponent(new XMLSerializer());
 
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
         pipeline.setup(baos);
         pipeline.execute();
 
-        String actualDocument = new String(baos.toByteArray(), "UTF-8");
+        final String actualDocument = new String(baos.toByteArray(), "UTF-8");
 
-        StringBuffer expectedDocumentBuffer = new StringBuffer();
-        BufferedReader in = new BufferedReader(
-                new InputStreamReader(
-                source.openStream()));
+        final StringBuffer expectedDocBuf = new StringBuffer();
+        final BufferedReader in = new BufferedReader(
+                new InputStreamReader(source.openStream()));
         String inputLine;
         while ((inputLine = in.readLine()) != null) {
-            expectedDocumentBuffer.append(inputLine);
-            expectedDocumentBuffer.append("\n");
+            expectedDocBuf.append(inputLine);
+            expectedDocBuf.append('\n');
         }
         in.close();
 
-        String expectedDocument = expectedDocumentBuffer.toString();
+        String expectedDocument = expectedDocBuf.toString();
         expectedDocument = expectedDocument.replaceAll(
                 "href=\"/", "href=\"http://www.apache.org/").replaceAll(
                 "href=\"\\./", "href=\"http://www.apache.org/").replaceAll(
                 "href=\"foundation", "href=\"http://www.apache.org/foundation");
 
-        Diff diff = new Diff(expectedDocument, actualDocument);
+        final Diff diff = new Diff(expectedDocument, actualDocument);
 
         assertTrue("LinkRewrite transformation didn't work as expected " + diff,
                 diff.identical());
     }
 
-    class AbsoluteLinkRewriterTransformer extends AbstractLinkRewriterTransformer {
+    @Test
+    public void testRegexpLinkRewriting()
+            throws Exception {
+
+        final URL source = this.getClass().getResource("/apache_home.html");
+
+        final Pipeline<SAXPipelineComponent> pipeline =
+                new NonCachingPipeline<SAXPipelineComponent>();
+        pipeline.addComponent(new XMLGenerator(source));
+
+        Map<String, String> regexpMap = new HashMap<String, String>();
+        regexpMap.put("^\\./([\\.]*)", "http://www.apache.org/$1");
+        regexpMap.put("^/([\\.]*)", "http://www.apache.org/$1");
+
+        final RegexpLinkRewriterTransformer regexpLrt =
+                new RegexpLinkRewriterTransformer(regexpMap);
+
+        regexpLrt.addElement("a", "href");
+        regexpLrt.addElement("http://www.w3.org/1999/xhtml",
+                "link",
+                RegexpLinkRewriterTransformer.ALL_NAMESPACES,
+                "href");
+        pipeline.addComponent(regexpLrt);
+
+        pipeline.addComponent(new XMLSerializer());
+
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        pipeline.setup(baos);
+        pipeline.execute();
+
+        final String actualDocument = new String(baos.toByteArray(), "UTF-8");
+
+        final StringBuffer expectedDocBuf = new StringBuffer();
+        final BufferedReader in = new BufferedReader(
+                new InputStreamReader(source.openStream()));
+        String inputLine;
+        while ((inputLine = in.readLine()) != null) {
+            expectedDocBuf.append(inputLine);
+            expectedDocBuf.append('\n');
+        }
+        in.close();
+
+        String expectedDocument = expectedDocBuf.toString();
+        expectedDocument = expectedDocument.replaceAll(
+                "href=\"\\./", "href=\"http://www.apache.org/").replaceAll(
+                "href=\"/", "href=\"http://www.apache.org/");
+
+        final Diff diff = new Diff(expectedDocument, actualDocument);
+
+        assertTrue("RegexpLinkRewrite transformation didn't work as expected "
+                + diff, diff.identical());
+    }
+
+    static class AbsoluteLinkRewriterTransformer
+            extends AbstractLinkRewriterTransformer {
+
+        @Override
+        public String rewrite(final String elementNS,
+                final String elementName,
+                final String attributeNS,
+                final String attributeName,
+                final String link)
+                throws LinkRewriterException {
+
+            String result;
+            if (link.startsWith("http")) {
+                result = link;
+            } else {
+                result = "http://www.apache.org"
+                        + (link.charAt(0) == '.'
+                        ? link.substring(1)
+                        : (link.charAt(0) == '/'
+                        ? link : "/" + link));
 
-        public String rewrite(String elementNamespace,
-                String elementName,
-                String attributeNamespace,
-                String attributeName,
-                String link) throws Exception {
-
-            if (!link.startsWith("http")) {
-                if (this.getLog().isInfoEnabled()) {
-                    this.getLog().info("Rewriting link '"
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Link '"
                             + link
+                            + "' rewritten to '"
+                            + result
                             + "'");
                 }
-
-                return "http://www.apache.org"
-                        + (link.startsWith(".")
-                        ? link.substring(1) : (!link.startsWith("/")
-                        ? "/" + link : link));
             }
-            return link;
+            return result;
         }
     }
-
 }

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-component.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-component.xml?rev=1080935&r1=1080934&r2=1080935&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-component.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-component.xml Sat Mar 12 13:55:07 2011
@@ -54,5 +54,7 @@
 
   <bean name="transformer:log" class="org.apache.cocoon.sax.component.LogTransformer" scope="prototype" />
 
+  <bean name="transformer:regexplinkrewriter" class="org.apache.cocoon.sax.component.RegexpLinkRewriterTransformer" scope="prototype" />
+
   <bean name="reader:file" class="org.apache.cocoon.sitemap.component.FileReaderComponent" scope="prototype" />
 </beans>