On Tue, 2007-12-11 at 11:54 +0100, Sina K. Heshmati wrote:
> Thorsten Scherler said:
>
> > On Mon, 2007-12-10 at 19:45 +0100, Sina K. Heshmati wrote:
> >> Thorsten,
> >>
> >> I've written a contract that generates an issue summary.
> >
> > How does this contract look like?
> >
> Here's the plugin code [2]. The contract is called 'baetle-issue-summary' and
> can be found in [3].
>
Try with:
<forrest:content>
<forrest:part>
<xsl:comment>+ |start baetle-issue-summary +</xsl:comment>
<xsl:variable name="node" select="[EMAIL
PROTECTED]'issueDetails']"/>
<div id="issueDetails">
<h3>
<xsl:value-of select="$node/title[1]"/>
</h3>
<xsl:copy-of select="$node/table"/>
</div>
<xsl:comment>+ |end baetle-issue-summary +</xsl:comment>
</forrest:part>
</forrest:content>
> >> The result should be dispatched in the sidebar but it fails because it
> >> cannot
> >> create a node --poor XPath support [1].
> >
> > How do you call it in your structurer?
> >
> <forrest:hook name="sidebar">
> <forrest:contract name="baetle-issue-summary"
> dataURI="cocoon://#{$getRequest}.issueSummary.xml"/>
> </forrest:hook>
With above code changed, the result of the contract will be injected in
the place where you call it. Meaning in our case within a <div
id="sidebar"/>. Exactly what you want, not?
Actually your content-baetle-link contract is doing it very right.
If you leave the xpath expression the contract violates the philosophy
of contracts in general since it is not flexible to place anywhere
I/you/anyone ones. It always wants to be injected in
"/html/body//[EMAIL PROTECTED]'sidebar']". VERY BAD!
The only case one is using <forrest:part xpath="/html/head"> is when you
need to inject something in the head of the page (like your
baetle-embedded contract).
"...
<!-- forrest:part within this element the actual content is going to.
If you use no @xpath then we insert content on the current structurer
position.-->
<forrest:part>
Content going to the location defined by the structurer.
</forrest:part>
<!--If you want to inject the content into a certain DOM position and
*not* the current position in the structurer, you can use the @xpath
attribute. -->
<forrest:part xpath="/html/head">
Content going to a fixed location defined by the contract (here: /html/head).
</forrest:part>
.."
http://svn.apache.org/viewvc/forrest/trunk/whiteboard/plugins/org.apache.forrest.themes.core/themes/common/html/master.ft?view=co
>
> Notes:
> (1) The hook is arbitrarily called 'sidebar' and is just an example, however
> a less generic name e.g. 'baetleIssue' is preferred.
>
> (2) The contract now uses the node generated by the wrapping hook to identify
> the target node.
>
> > Can you please outline what are you trying to do?
> >
> Now, the dispatcher selects the wrong target node, e.g. right before </body>
> as a place to insert the chunk generated by the contract, which is not the
> desired behaviour. In other words, how can I have my content appear wherever
> I want and keep the structurer as clean as possible?
See above.
HTH
salu2
>
> -SinDoc
>
> >>
> >> [1] http://marc.info/?l=forrest-dev&m=118803688000385&w=2
> [2]https://issues.apache.org/jira/secure/attachment/12371418/FOR-1038-baetle-20071211-03.zip
> [3] ${PLUGIN_HOME}/resources/themes/common/html/
> [4]
> ${PLUGIN_HOME}/src/documentation/resources/structurer/url/samples/bissues/pelt.fv
>
--
Thorsten Scherler thorsten.at.apache.org
Open Source Java consulting, training and solutions