You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Olivier Lange <wi...@petit-atelier.ch> on 2003/05/18 23:26:22 UTC

LinkRewriter transformer namespace configuration (Cocoon 2.1M1)

Still about the LinkRewriter's configuration, as of Cocoon 2.1M1, there is
another hint perhaps worth mentionning here: it is possible to change the
namespace of the elements handled by the LinkRewriter transformer by
defining a "namespaceURI" parameter to the transformer in the sitemap.

This might seem obvious... indeed, this parameter is available to all
transformer, as it is defined in the AbstractSAXTransformer abstract class,
base of all transformers. But I didn't see it at first, until Jeff Turner
refered me to the AbstractSAXTransformer source code.

Thus, if one wants the LinkRewriter to handle elements from the XHTML
namespace, one would write:

  <map:transform type="linkrewriter" src="cocoon:/{1}/linkmap.abs.xml">

    <!-- Changing Linkrewriter's processed namespace -->
    <map:parameter name="namespaceURI"
value="http://www.w3.org/1999/xhtml"/>

    <!-- Other LinkRewriter parameters -->
    <map:parameter name="link-attrs" value="href src onmouseover
onmouseout"/>
    <map:parameter name="schemes" value="phga external"/>
    <map:parameter name="exclude-schemes" value="http https ftp mailto
news"/>
    <map:parameter name="bad-link-str" value="bad-link"/>
  </map:transform>

If not already done, may I suggest adding a comment to the Javadoc for this
hint? Thanks!

Olivier


-----Message d'origine-----
De : Olivier Lange [mailto:olange@petit-atelier.ch]
Envoyé : dimanche, 11. mai 2003 06:10
À : cocoon-users@xml.apache.org; jefft@apache.org
Objet : Linkrewriter dynamic configuration overloading syntax pitfall
(Javadoc out of sync, Cocoon 2.1M1)


Dear all

I had a hard time figuring out how to dynamically overload the configuration
of the input modules used for the LinkRewriter configuration. I believe
there is a syntax pitfall in the Javadoc of Cocoon 2.1M1, the Javadoc being
out of sync on this topic.

I discovered the Linkrewriter in Forrest 0.4, studied its configuration,
then followed the Javadoc and overlooked the sitemap configuration of the
bookdemo and sitedemo samples of Cocoon 2.1M1. Here is a summary.

The Javadoc notes that the "dynamic config syntax [is] different to the
static config syntax (attributes used instead of elements)"
(LinkRewriterTransformer.java, lines 114-116). So one is suggested to write:

<map:sitemap>
  <map:components>
    <map:transformers>
      <map:transformer name="linkrewriter"
        src="org.apache.cocoon.transformation.LinkRewriterTransformer">
        ...
        <input-module name="linkmap" src="{src}" ... />
        ...                          ^^^ attribute: does not work
      </map:transformer>

I tried, but this didn't work. The linkwriter would not use the sitemap's
substitued value of the 'src' attribute to get the "Linkmap", it rather used
the value of the static configuration defined in the cocoon.xconf file:

  <component-instance name="linkmap" ...>
    ...
    <file src="cocoon://linkmap"/>
    ...
  </component-instance>

To dynamically overload the cocoon.xconf's static configuration, one has to
write:

  <map:transformer name="linkrewriter" src="..."
    ...
    <input-module name="linkmap" ... >
      <file src="{src}"/>
    </input-module>
    ...
  </map:transformer>

There is actually no difference to the static configuration syntax. The
samples use this later syntax and work fine.

Olivier



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