You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by bu...@apache.org on 2002/12/22 16:40:35 UTC

DO NOT REPLY [Bug 15611] New: - [PATCH] LinkRewriterTransformer: using InputModules in Transformers

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15611>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15611

[PATCH] LinkRewriterTransformer: using InputModules in Transformers

           Summary: [PATCH] LinkRewriterTransformer: using InputModules in
                    Transformers
           Product: Cocoon 2
           Version: Current CVS
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: sitemap components
        AssignedTo: cocoon-dev@xml.apache.org
        ReportedBy: jefft@apache.org


Hi all,

With help from Chris, I've written the attached transformer which rewrites
attributes deemed to be links (typically @href or @src). It treats a link URI as
an InputModule 'address', and uses the appropriate InputModule to rewrite the
link. Reusing InputModules like this gives this transformer a lot of bang for
buck :)

The canonical example is to set up an XMLFileModule, which accesses node values
from an XML document. Say we load the following XML doc into an XMLFileModule
called 'linkmap':

<site>
  <input href="index.html"/>
  <primer href="primer.html"/>
</site>

Then a link, <link href="linkmap:/site/index/@href"> will be rewritten as <link
href="index.html">.  As InputModules can be chained, we can put a
SimpleMappingMetaModule in front of this to simplify the source URI to <link
href="site:index">.

The two attached sample subsitemaps demonstrate the transformer.  One implements
the above example, and the other uses book.xml @label attributes to translate
links like 'book:Introduction' into 'introduction.html', or
'../introduction.html' etc (depending on directory).

The intention is to use this in Forrest to implement the linking system
described at http://marc.theaimsgroup.com/?l=forrest-dev&m=103444028129281&w=2
and furthermore to implement a range of link 'schemes', eg convert <link
href="person:JT"> to <a href="mailto:jefft at apache dot org">.

While the transformer I've implemented happens to rewrite links, this
transformer could be generalized to transform any part of the incoming XML. For
example, we could rewrite any occurrence of ${scheme:address} in the source XML.

All feedback appreciated.  The code has been tested to the extent of developing
the samples, and should improve as I try it out in Forrest.


--Jeff

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