forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <>
Subject Re: Using javax.xml.xpath
Date Tue, 11 Dec 2007 11:16:15 GMT
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:
            <xsl:comment>+ |start baetle-issue-summary +</xsl:comment>
	      <xsl:variable name="node" select="section[@id='issueDetails']"/>
	      <div id="issueDetails">
		  <xsl:value-of select="$node/title[1]"/>
  	        <xsl:copy-of select="$node/table"/>
            <xsl:comment>+ |end baetle-issue-summary +</xsl:comment>

> >> 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//div[@id='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.-->
  Content going to the location defined by the structurer.
<!--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).

> 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
> > 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.



> -SinDoc
> >>
> >> [1]
> [2]
> [3] ${PLUGIN_HOME}/resources/themes/common/html/
> [4] ${PLUGIN_HOME}/src/documentation/resources/structurer/url/samples/bissues/pelt.fv
Thorsten Scherler                       
Open Source Java                      consulting, training and solutions

View raw message