You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@forrest.apache.org by Thorsten Scherler <th...@apache.org> on 2005/11/22 12:03:08 UTC
hooks injection (was Re: DispatcherTransformer.java )
El lun, 21-11-2005 a las 12:04 +0000, Ross Gardler escribió:
...
> >>>>The question is how can we make contracts more generic. One way is to
> >>>>get rid of head|body="true|false". I thought that each contract has to
> >>>>provide this information from the resulting transformation.
>
> ...
>
> >>How about:
> >>
> >><content xpath="/html/body">
> >> <!-- the HTML generated by the contract -->
> >></content>
> >>
>
> ...
>
> > Assuming forrest:hook will be transformed to div id="test" the location
> > would be
> > xpath="html/body/div[@id='test']"
> >
> > I call this <content xpath="html/body"/> xpath structure aware, because
> > it is more a xpath prefix then a fixed location.
> >
> > Now think you would add
> > <content xpath="html/head">
> > <something/>
> > </content>
> >
> > That should not be aware of the structure. It should be insert in the
> > fixed location "html/head" otherwise you would get invalid markup.
> >
> > To solve this problem I would like to propose to add an attribute
> > fixedLocation="true|false". So this makes
> > <content xpath="html/head" fixedLocation="true">
> > <something/>
> > </content>
> >
> > I propose to make the default fixedLocation="false". That means the
> > content will be injected in the overall structure defined by the
> > structurer (*.fv), the content is structure aware.
>
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.
<forrest:view type="html" hooksXpath="/html/body">
<forrest:hook name="htmlBodyHook"/>
</forrest:view>
that will be transformed into
<html>
<body>
<forrest:hook name="htmlBodyHook"/>
</body>
</html>
I propose this attribute @hooksXpath as required.
***
I as well thought about another attribute @xpath for the forrest:hooks,
but that does not convinced me much:
<forrest:view type="html" hooksDefaultXpath="/html/body">
<forrest:hook name="htmlBodyHookHook"
xpath="/html/body/forrest:hook[@name='htmlBodyHook']"/>
</forrest:view>
what is the same as:
<forrest:view type="html" hooksDefaultXpath="/html/body">
<forrest:hook name="htmlBodyHook">
<forrest:hook name="htmlBodyHookHook"/>
</forrest:hook>
</forrest:view>
that will be transformed into
<html>
<body>
<forrest:hook name="htmlBodyHook">
<forrest:hook name="htmlBodyHookHook"/>
</forrest:hook>
</body>
</html>
True with this attribute one would be super flexible but still I am
afraid that the structurer then will become pretty fast very complex and
against its logic because of something like:
<forrest:view type="html" hooksDefaultXpath="/">
<forrest:hook name="htmlBodyHook" xpath="/html/body">
<forrest:hook name="htmlBodyAnotherHook" xpath="/html/body"/>
</forrest:hook>
</forrest:view>
that will be transformed into
<html>
<body>
<forrest:hook name="htmlBodyHook"/>
<forrest:hook name="htmlBodyAnotherHook"/>
</body>
</html>
That just does not feels right because in the structurer
htmlBodyAnotherHook is child of htmlBodyHook but in the resulting
transformation not anymore.
WDYT?
salu2
--
thorsten
"Together we stand, divided we fall!"
Hey you (Pink Floyd)
Re: hooks injection (was Re: DispatcherTransformer.java )
Posted by Thorsten Scherler <th...@apache.org>.
El mar, 22-11-2005 a las 15:22 +0100, Cyriaque Dupoirieux escribió:
> I like it too,
>
> Can you remind me what :
> <forrest:view type="html" hooksXpath="/html/head">
> <forrest:hook name="htmlHeadHook"/>
> </forrest:view>
>
> will generate ?
<html>
<head>
<forrest:hook name="htmlHeadHook"/>
</head>
<html>
salu2
--
thorsten
"Together we stand, divided we fall!"
Hey you (Pink Floyd)
Re: hooks injection (was Re: DispatcherTransformer.java )
Posted by Thorsten Scherler <th...@apache.org>.
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)
Re: hooks injection (was Re: DispatcherTransformer.java )
Posted by Ross Gardler <rg...@apache.org>.
> Ross Gardler a écrit :
>
>> Thorsten Scherler wrote:
>>
>>> El mar, 22-11-2005 a las 12:51 +0000, Ross Gardler escribió:
>>>
>>>> Thorsten Scherler wrote:
>>>>
>>>>> El lun, 21-11-2005 a las 12:04 +0000, Ross Gardler escribió: ...
...
>>>>>>> I propose to make the default fixedLocation="false". That means the
>>>>>>> content will be injected in the overall structure defined by the
>>>>>>> structurer (*.fv), the content is structure aware.
>>>>>>
>>>>>>
>>>>>>
>>>>> 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?
Ross
Re: hooks injection (was Re: DispatcherTransformer.java )
Posted by Cyriaque Dupoirieux <Cy...@pcotech.fr>.
Ross Gardler a écrit :
> Thorsten Scherler wrote:
>
>> El mar, 22-11-2005 a las 12:51 +0000, Ross Gardler escribió:
>>
>>> Thorsten Scherler wrote:
>>>
>>>> El lun, 21-11-2005 a las 12:04 +0000, Ross Gardler escribió: ...
>>>>
>>>>
>>>>>>>>> The question is how can we make contracts more generic. One
>>>>>>>>> way is to
>>>>>>>>> get rid of head|body="true|false". I thought that each
>>>>>>>>> contract has to
>>>>>>>>> provide this information from the resulting transformation.
>>>>>>>>
>>>>>
>>>>> ...
>>>>>
>>>>>
>>>>>
>>>>>>> How about:
>>>>>>>
>>>>>>> <content xpath="/html/body">
>>>>>>> <!-- the HTML generated by the contract -->
>>>>>>> </content>
>>>>>>>
>>>>> ...
>>>>>
>>>>>
>>>>>
>>>>>> Assuming forrest:hook will be transformed to div id="test" the
>>>>>> location
>>>>>> would be
>>>>>> xpath="html/body/div[@id='test']"
>>>>>>
>>>>>> I call this <content xpath="html/body"/> xpath structure aware,
>>>>>> because
>>>>>> it is more a xpath prefix then a fixed location.
>>>>>>
>>>>>> Now think you would add <content xpath="html/head">
>>>>>> <something/>
>>>>>> </content>
>>>>>>
>>>>>> That should not be aware of the structure. It should be insert in
>>>>>> the
>>>>>> fixed location "html/head" otherwise you would get invalid markup.
>>>>>>
>>>>>> To solve this problem I would like to propose to add an attribute
>>>>>> fixedLocation="true|false". So this makes <content
>>>>>> xpath="html/head" fixedLocation="true">
>>>>>> <something/>
>>>>>> </content>
>>>>>>
>>>>>> I propose to make the default fixedLocation="false". That means the
>>>>>> content will be injected in the overall structure defined by the
>>>>>> structurer (*.fv), the content is structure aware.
>>>>>
>>>>>
>>>> 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.
>>>
>>
>>
>> Actually it is html vs. any format. Html makes it necessary that hooks
>> are placed into a certain location. Otherwise you would get the hooks
>> transformed into the root.
>
>
> Of course, obvious really!
>
>>>> <forrest:view type="html" hooksXpath="/html/body">
>>>> <forrest:hook name="htmlBodyHook"/>
>>>> </forrest:view>
>>>>
>>>> that will be transformed into <html>
>>>> <body>
>>>> <forrest:hook name="htmlBodyHook"/>
>>>> </body>
>>>> </html>
>>>>
>>>> I propose this attribute @hooksXpath as required.
>>>
>>>
>>> This makes the assumption that all hooks are to be placed in the
>>> same location within the output file. Can we safely make that
>>> assumption? Can we imagine a situation where we have a single view
>>> defining hooks that go into a different place?
>>
>>
>>
>> That would be possible by defining hooksXpath="/" and then generating
>> the path with hooks.
>> Maybe we need another attribute in hooks @element which would not create
>> a div but the value of @element:
>> <forrest:hook element="html">
>> <forrest:hook element="body">
>> <forrest:hook name="htmlBodyHook"/>
>> </forrest:hook>
>> </forrest:hook>
>>
>> that will be transformed into
>>
>>> <html>
>>> <body>
>>> <forrest:hook name="htmlBodyHook"/>
>>> </body>
>>> </html>
>>
>>
>>
>> wdyt?
>
>
> +1
I like it too,
Can you remind me what :
<forrest:view type="html" hooksXpath="/html/head">
<forrest:hook name="htmlHeadHook"/>
</forrest:view>
will generate ?
Salutations,
Cyriaque,
>
> Ross
>
>
>
Re: hooks injection (was Re: DispatcherTransformer.java )
Posted by Ross Gardler <rg...@apache.org>.
Thorsten Scherler wrote:
> El mar, 22-11-2005 a las 12:51 +0000, Ross Gardler escribió:
>
>>Thorsten Scherler wrote:
>>
>>>El lun, 21-11-2005 a las 12:04 +0000, Ross Gardler escribió:
>>>...
>>>
>>>
>>>>>>>>The question is how can we make contracts more generic. One way is to
>>>>>>>>get rid of head|body="true|false". I thought that each contract has to
>>>>>>>>provide this information from the resulting transformation.
>>>>
>>>>...
>>>>
>>>>
>>>>
>>>>>>How about:
>>>>>>
>>>>>><content xpath="/html/body">
>>>>>> <!-- the HTML generated by the contract -->
>>>>>></content>
>>>>>>
>>>>...
>>>>
>>>>
>>>>
>>>>>Assuming forrest:hook will be transformed to div id="test" the location
>>>>>would be
>>>>>xpath="html/body/div[@id='test']"
>>>>>
>>>>>I call this <content xpath="html/body"/> xpath structure aware, because
>>>>>it is more a xpath prefix then a fixed location.
>>>>>
>>>>>Now think you would add
>>>>><content xpath="html/head">
>>>>><something/>
>>>>></content>
>>>>>
>>>>>That should not be aware of the structure. It should be insert in the
>>>>>fixed location "html/head" otherwise you would get invalid markup.
>>>>>
>>>>>To solve this problem I would like to propose to add an attribute
>>>>>fixedLocation="true|false". So this makes
>>>>><content xpath="html/head" fixedLocation="true">
>>>>><something/>
>>>>></content>
>>>>>
>>>>>I propose to make the default fixedLocation="false". That means the
>>>>>content will be injected in the overall structure defined by the
>>>>>structurer (*.fv), the content is structure aware.
>>>>
>>>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.
>>
>
>
> Actually it is html vs. any format. Html makes it necessary that hooks
> are placed into a certain location. Otherwise you would get the hooks
> transformed into the root.
Of course, obvious really!
>>><forrest:view type="html" hooksXpath="/html/body">
>>> <forrest:hook name="htmlBodyHook"/>
>>></forrest:view>
>>>
>>>that will be transformed into
>>><html>
>>> <body>
>>> <forrest:hook name="htmlBodyHook"/>
>>> </body>
>>></html>
>>>
>>>I propose this attribute @hooksXpath as required.
>>
>>This makes the assumption that all hooks are to be placed in the same
>>location within the output file. Can we safely make that assumption? Can
>>we imagine a situation where we have a single view defining hooks that
>>go into a different place?
>
>
> That would be possible by defining hooksXpath="/" and then generating
> the path with hooks.
>
> Maybe we need another attribute in hooks @element which would not create
> a div but the value of @element:
> <forrest:hook element="html">
> <forrest:hook element="body">
> <forrest:hook name="htmlBodyHook"/>
> </forrest:hook>
> </forrest:hook>
>
> that will be transformed into
>
>> <html>
>> <body>
>> <forrest:hook name="htmlBodyHook"/>
>> </body>
>> </html>
>
>
> wdyt?
+1
Ross
Re: hooks injection (was Re: DispatcherTransformer.java )
Posted by Thorsten Scherler <th...@apache.org>.
El mar, 22-11-2005 a las 12:51 +0000, Ross Gardler escribió:
> Thorsten Scherler wrote:
> > El lun, 21-11-2005 a las 12:04 +0000, Ross Gardler escribió:
> > ...
> >
> >>>>>>The question is how can we make contracts more generic. One way is to
> >>>>>>get rid of head|body="true|false". I thought that each contract has to
> >>>>>>provide this information from the resulting transformation.
> >>
> >>...
> >>
> >>
> >>>>How about:
> >>>>
> >>>><content xpath="/html/body">
> >>>> <!-- the HTML generated by the contract -->
> >>>></content>
> >>>>
> >>...
> >>
> >>
> >>>Assuming forrest:hook will be transformed to div id="test" the location
> >>>would be
> >>>xpath="html/body/div[@id='test']"
> >>>
> >>>I call this <content xpath="html/body"/> xpath structure aware, because
> >>>it is more a xpath prefix then a fixed location.
> >>>
> >>>Now think you would add
> >>><content xpath="html/head">
> >>> <something/>
> >>></content>
> >>>
> >>>That should not be aware of the structure. It should be insert in the
> >>>fixed location "html/head" otherwise you would get invalid markup.
> >>>
> >>>To solve this problem I would like to propose to add an attribute
> >>>fixedLocation="true|false". So this makes
> >>><content xpath="html/head" fixedLocation="true">
> >>> <something/>
> >>></content>
> >>>
> >>>I propose to make the default fixedLocation="false". That means the
> >>>content will be injected in the overall structure defined by the
> >>>structurer (*.fv), the content is structure aware.
> >>
> >
> > 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.
>
Actually it is html vs. any format. Html makes it necessary that hooks
are placed into a certain location. Otherwise you would get the hooks
transformed into the root.
e.g. for a view type="xml" @hooksXpath="/"
<forrest:hook name="test">
<forrest:hook name="test2"/>
</forrest:hook>
may be (depends on the hooks-to-xml.xsl) transformed to
<test>
<test2/>
</test>
like said above in html that would not make sense since everything has
to go to /html/head or /html/body.
> >
> > <forrest:view type="html" hooksXpath="/html/body">
> > <forrest:hook name="htmlBodyHook"/>
> > </forrest:view>
> >
> > that will be transformed into
> > <html>
> > <body>
> > <forrest:hook name="htmlBodyHook"/>
> > </body>
> > </html>
> >
> > I propose this attribute @hooksXpath as required.
>
> This makes the assumption that all hooks are to be placed in the same
> location within the output file. Can we safely make that assumption? Can
> we imagine a situation where we have a single view defining hooks that
> go into a different place?
That would be possible by defining hooksXpath="/" and then generating
the path with hooks.
Maybe we need another attribute in hooks @element which would not create
a div but the value of @element:
<forrest:hook element="html">
<forrest:hook element="body">
<forrest:hook name="htmlBodyHook"/>
</forrest:hook>
</forrest:hook>
that will be transformed into
> <html>
> <body>
> <forrest:hook name="htmlBodyHook"/>
> </body>
> </html>
>
> If not then you proposal is good.
wdyt?
--
thorsten
"Together we stand, divided we fall!"
Hey you (Pink Floyd)
Re: hooks injection (was Re: DispatcherTransformer.java )
Posted by Ross Gardler <rg...@apache.org>.
Thorsten Scherler wrote:
> El lun, 21-11-2005 a las 12:04 +0000, Ross Gardler escribió:
> ...
>
>>>>>>The question is how can we make contracts more generic. One way is to
>>>>>>get rid of head|body="true|false". I thought that each contract has to
>>>>>>provide this information from the resulting transformation.
>>
>>...
>>
>>
>>>>How about:
>>>>
>>>><content xpath="/html/body">
>>>> <!-- the HTML generated by the contract -->
>>>></content>
>>>>
>>...
>>
>>
>>>Assuming forrest:hook will be transformed to div id="test" the location
>>>would be
>>>xpath="html/body/div[@id='test']"
>>>
>>>I call this <content xpath="html/body"/> xpath structure aware, because
>>>it is more a xpath prefix then a fixed location.
>>>
>>>Now think you would add
>>><content xpath="html/head">
>>> <something/>
>>></content>
>>>
>>>That should not be aware of the structure. It should be insert in the
>>>fixed location "html/head" otherwise you would get invalid markup.
>>>
>>>To solve this problem I would like to propose to add an attribute
>>>fixedLocation="true|false". So this makes
>>><content xpath="html/head" fixedLocation="true">
>>> <something/>
>>></content>
>>>
>>>I propose to make the default fixedLocation="false". That means the
>>>content will be injected in the overall structure defined by the
>>>structurer (*.fv), the content is structure aware.
>>
>
> 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.
>
> <forrest:view type="html" hooksXpath="/html/body">
> <forrest:hook name="htmlBodyHook"/>
> </forrest:view>
>
> that will be transformed into
> <html>
> <body>
> <forrest:hook name="htmlBodyHook"/>
> </body>
> </html>
>
> I propose this attribute @hooksXpath as required.
This makes the assumption that all hooks are to be placed in the same
location within the output file. Can we safely make that assumption? Can
we imagine a situation where we have a single view defining hooks that
go into a different place?
If not then you proposal is good.
Ross