forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <thors...@apache.org>
Subject Re: hooks injection (was Re: DispatcherTransformer.java )
Date Tue, 22 Nov 2005 17:39:48 GMT
El mar, 22-11-2005 a las 16:43 +0000, Ross Gardler escribió:
...
> >>>>> A similar problem is with hooks. Till now we assumed that all hooks
go
> >>>>> into /html/body but this need to be more flexible. I propose to
add a
> >>>>> new attribute @hooksXpath to the forrest:view.
> >>>>
> >>>>
> >>>>
> >>>> I'm not sure I can see a use case for this, I'll respond assuming 
> >>>> you have one, but an example may help.
> 
> Here's another use case that just emerged for me, I wonder if your 
> proposal can cope with this one.
> 
> The output format is still HTML, but I want to be able to insert the 
> output of a contract (and hook) at a specific point in the document. The 
> contract provides a form field for adding notes to a document. So I 
> might have a source document like this:
> 
> <document>
>    ...
>    <body>
>      <section id="overview">
>        <title>Overview</title>
>        ...
>      </section>
>      <section id="background">
>        <title>Background</title>
>        ...
>      </section>
> <document>
> 
> What I might want output is this:
> 
> <html>
>    ...
>    <body>
>      <div id="overview">
>        <h1>Overview</h1>
>        ...
>        <div id="overviews-notes">
>          <!-- content from contract here -->
>        </div>
>      </div>
> 
>      <div>
>        <h1>Background</h1>
>        ...
>        <div id="overviews-notes">
>          <!-- content from contract here -->
>        </div>
>      </div>
>    <body>
>    ...
> <html>
> 
> Since the contract is inserted into a number of places with different 
> properties depending on the structure of the original source file I 
> expect that the structurer will be dynamically created by my project 
> sitemap.
> 
> My question is can I create a structurer that will insert the contract 
> output into the page content in this way? If so what would it look like?
> 

Ok, IMO it could be possible in different ways (not tested yet, because
not yet 100% implemented in the dispatcherTransformer). 

One way is like you said to do it via the hooks:
<forrest:view type="html" hooksXpath="/html/body">
 <forrest:hook name="overview">
  <forrest:hook name="overviews-notes">
   <forrest:contract/>
  </forrest:hook>
 </forrest:hook>
</forrest:view>

Another way to define the fixed location in the contract via content
xpath="/html/body/div[@id='overview']/div[@id='overview']"

...but that may cause problems because you are now trying to extend the
"content-main" contract result and I am not sure whether that will be
cause problems with the DOM (it may not be inserted in exact position
you want). I need to try that with the transformer whether that is
possible and how.

salu2
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Mime
View raw message