cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ovidiu Predescu <ovi...@apache.org>
Subject Re: mental note (WAS Common practice: how to keep links to html-trees consistent)
Date Sun, 01 Sep 2002 05:37:44 GMT
On Wednesday, August 28, 2002, at 01:00 AM, Steven Noels wrote:

> Something we still should think about (still catching up on mail):
>
> http://marc.theaimsgroup.com/?t=102978950000005&r=1&w=2
>
> </Steven>

Thanks for pointing this out. To solve the problem I came up some time 
ago with a simple transformer which augments the href attribute of any 
element with the full path. The full path can be specified in the 
sitemap like below:

   <map:components>
     <map:transformers default="xslt">
      <map:transformer name="augment"
                       
src="org.apache.cocoon.transformation.AugmentTransformer"
                       mime-type="text/xml"
                       logger="sitemap.transformer.augment"/>
     </map:transformers>
   </map:components>

       <map:match pattern="doc/*.html">
         <map:generate src="docs/{1}.xml"/>
         <map:transform type="augment">
           <map:parameter name="mount" value="samples/flow/"/>
         </map:transform>
         <map:transform 
src="context://documentation/stylesheets/document2html.xsl"/>
         <map:serialize type="xml"/>
       </map:match>

In this example for any request for a document from the docs/ 
directory, the source XML document is first processed through the 
"augment" transformer, defined in the map:components as above. This 
replaces all the href attributes of any element with the concatenated 
value of the "mount" attribute followed by the original value of the 
attribute. E.g. in our sample if we had an element in the original XML 
doc like

<link href="index.html"/>

This becomes

<link href="samples/flow/index.html"/>

after the processing.

Regards,
-- 
Ovidiu Predescu <ovidiu@apache.org>
http://webweavertech.com/ovidiu/weblog/ (Weblog)
http://www.geocities.com/SiliconValley/Monitor/7464/ (Apache, GNU, 
Emacs ...)


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message