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/09/11 17:48:52 UTC

[Fwd: Re: [views] nugget contracts broken]

-- 
thorsten

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

Re: [Fwd: Re: [views] nugget contracts broken]

Posted by Thorsten Scherler <th...@apache.org>.
On Sun, 2005-09-11 at 20:59 +0100, Ross Gardler wrote: 
> Thorsten Scherler wrote:
> > I think no nugget should work. :(
> > svn diff -r225411:HEAD resources/stylesheets/prepare.xhtml.xsl
> > - <alias:with-param name="{@name}"
> > select=".//forrest:properties[@contract='{$name}']/forrest:property[@name='{@name}']"/>
> > + <alias:with-param name="{@name}" select="'{normalize-space(.)}'"/>
> > 
> > This is the problem. Now you cannot pass xml-snippet as param anymore.
> > It is quite complicated to calculate the right xpath expression only in
> > xsl

Actually that is completely untrue what I said here! Sorry!

It is *very easy* to generate an xpath expression in xsl - it is the
nature of xpath that makes it so easy . ;-)

- <alias:with-param name="{@name}" select="'{normalize-space(.)}'"/>
+ <xsl:variable name="xpath">
+  <xsl:value-of select="'/site'"/>
+  <xsl:call-template name="generateXPath"/>
+ </xsl:variable>
+ <alias:with-param name="{@name}" select="{normalize-space($xpath)}"/>
...
+    <xsl:template name="generateXPath">
+      <xsl:for-each select="ancestor::*[name()!='filter']">
+        /<xsl:value-of select="name()"/>[<xsl:number/>]
+      </xsl:for-each>
+      /<xsl:value-of select="name()"/>[<xsl:number/>]
+    </xsl:template> 

I only had a hard time because of the forrest:filter element and its
namespace. The forrest namespace is not defined in the document
aggregation in the sitemap that causes errors in the xpath. So I striped
the ns. ;-)

...

> > I will have a look on how we can fixed that but I guess I will as well
> > look into how to solve that with java.
> 
> I have no suggestion for a solution, however, if it is any consolation I 
> like the idea of moving it into Java since we can add cachng later on 
> (XIncludes can't be cached).

Actually if we use cinclude for the nuggets contracts instead we would
have caching as well. We just need to change that. ;-)

Generally the "magic" part can stay like this till we decided whether we
want to write a generator or a transformer for it. 

I will play with it when I find time.

> It's also good that you found this, because I was having big problems 
> with using nuggets to do the navigation in the XHTML2 plugin. I'd not 
> had time to debug it (hence no ideas yer), but the symptoms sound the same.
> 
> Ross

Please test whether that solves your problem.
http://svn.apache.org/viewcvs?rev=280213&view=rev 

salu2
-- 
thorsten

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


Re: [Fwd: Re: [views] nugget contracts broken]

Posted by Ross Gardler <rg...@apache.org>.
Thorsten Scherler wrote:
> I think no nugget should work. :(
> svn diff -r225411:HEAD resources/stylesheets/prepare.xhtml.xsl
> - <alias:with-param name="{@name}"
> select=".//forrest:properties[@contract='{$name}']/forrest:property[@name='{@name}']"/>
> + <alias:with-param name="{@name}" select="'{normalize-space(.)}'"/>
> 
> This is the problem. Now you cannot pass xml-snippet as param anymore.
> It is quite complicated to calculate the right xpath expression only in
> xsl
> (//forrest:properties[@contract='{$name}']/forrest:property[@name='{@name}'] that is not right either because it will include not the right contract if you have two). This is one place where in java that would be peace of cake.
> 
> I will have a look on how we can fixed that but I guess I will as well
> look into how to solve that with java.

I have no suggestion for a solution, however, if it is any consolation I 
like the idea of moving it into Java since we can add cachng later on 
(XIncludes can't be cached).

It's also good that you found this, because I was having big problems 
with using nuggets to do the navigation in the XHTML2 plugin. I'd not 
had time to debug it (hence no ideas yer), but the symptoms sound the same.

Ross

Re: [Fwd: Re: [views] nugget contracts broken]

Posted by Thorsten Scherler <th...@apache.org>.
I think no nugget should work. :(
svn diff -r225411:HEAD resources/stylesheets/prepare.xhtml.xsl
- <alias:with-param name="{@name}"
select=".//forrest:properties[@contract='{$name}']/forrest:property[@name='{@name}']"/>
+ <alias:with-param name="{@name}" select="'{normalize-space(.)}'"/>

This is the problem. Now you cannot pass xml-snippet as param anymore.
It is quite complicated to calculate the right xpath expression only in
xsl
(//forrest:properties[@contract='{$name}']/forrest:property[@name='{@name}'] that is not right either because it will include not the right contract if you have two). This is one place where in java that would be peace of cake.

I will have a look on how we can fixed that but I guess I will as well
look into how to solve that with java.

salu2


On Sun, 2005-09-11 at 17:48 +0200, Thorsten Scherler wrote:
> email message attachment, "Forwarded message - Re: [views] nugget
> contracts broken"
> On Sun, 2005-09-11 at 17:48 +0200, Thorsten Scherler wrote:
> > On Sun, 2005-09-11 at 11:07 -0400, Tim Williams wrote:
> > > I was getting a similar error yesterday and build clean; build and
> > > re-deployed all plugins and it magically worked.  You probably tried
> > > this already but doing that up front would have saved me some time so
> > > I thought I'd throw it out there.
> > > --tim
> > 
> > I just did that again but still I see the error.
> > 
> > Can you paste the nugget-contract that is working for you, where you
> > include an external url into a contract?
> > 
> > Like:
> > <forrest:contract name="content-feeder">
> >     <forrest:properties contract="content-feeder">
> >       <forrest:property name="content-feeder"
> > nugget="get.nugget.feeder">
> >         <url>aggregateDescriptor.rss.xml</url>
> >       </forrest:property>
> >     </forrest:properties>
> > </forrest:contract>
> > 
> > <xsl:template name="content-feeder-body" >
> >  <xsl:param name="content-feeder"/>
> >   <xsl:apply-templates select="$content-feeder/document"/>		
> > </xsl:template>
> > 
> > TIA
> > 
> > salu2
> > > 
> > > On 9/11/05, Thorsten Scherler <th...@apache.org> wrote:
> > > > Hi all,
> > > > 
> > > > I have some problems with nugget contracts. It seems that the xinclude
> > > > is not working properly or does not get picked up on the last
> > > > transformation step. The *.page match contains the include but with
> > > > namespaces:
> > > > <forrest:contract name="content-feeder">
> > > >     <forrest:properties contract="content-feeder">
> > > >      <forrest:property xmlns:alias="http://www.w3.org/1999/XSL/Transform" xmlns:xi="http://www.w3.org/2001/XInclude" name="content-feeder">
> > > >         ...
> > > >      </forrest:property>
> > > >     </forrest:properties>
> > > > </forrest:contract>
> > > > 
> > > > Now on the *.html match I get the error.
> > > > ERROR   (2005-09-11) 16:48.14:861   [access] (/index.html)
> > > > PoolThread-4/CocoonServlet: Internal Cocoon Problem
> > > > org.apache.cocoon.ProcessingException: Failed to process pipeline
> > > >         at [cause location] - cocoon://prepare.include.xhtml.index:16:61
> > > >         at <map:serialize type="xml"> -
> > > > file:/home/thorsten/apache/forrest-trunk/build/plugins/org.apache.forrest.plugin.internal.view/internal.xmap:219:36
> > > >         at <map:serialize type="xhtml"> -
> > > > file:/home/thorsten/apache/forrest-trunk/build/plugins/org.apache.forrest.plugin.output.viewHelper.xhtml/output.xmap:255:36
> > > >         at <map:transform> -
> > > > file:/home/thorsten/apache/forrest-trunk/build/plugins/org.apache.forrest.plugin.output.viewHelper.xhtml/output.xmap:254:72
> > > >         at <map:transform> -
> > > > file:/home/thorsten/apache/forrest-trunk/build/plugins/org.apache.forrest.plugin.output.viewHelper.xhtml/output.xmap:251:61
> > > >         at <map:generate> -
> > > > file:/home/thorsten/apache/forrest-trunk/build/plugins/org.apache.forrest.plugin.output.viewHelper.xhtml/output.xmap:250:46
> > > >         at <map:mount> -
> > > > file:/home/thorsten/src/testSeed/build/tmp/output.xmap:38:152
> > > >         at <map:mount> -
> > > > file:/guada/home/thorsten/apache/forrest-trunk/main/webapp/sitemap.xmap:554:113
> > > >         at org.apache.cocoon.ProcessingException.throwLocated(Unknown
> > > > Source)
> > > > ...
> > > > Caused by: javax.xml.transform.TransformerException:
> > > > java.lang.ClassCastException: org.apache.xpath.objects.XString
> > > >         at
> > > > org.apache.cocoon.transformation.TraxTransformer.endDocument(Unknown
> > > > Source)
> > > >         at
> > > > org.apache.cocoon.environment.internal.EnvironmentChanger.endDocument(Unknown Source)
> > > >         at
> > > > org.apache.cocoon.sitemap.DefaultContentAggregator.generate(Unknown
> > > > Source)
> > > >         ... 56 more
> > > > Caused by: javax.xml.transform.TransformerException:
> > > > java.lang.ClassCastException: org.apache.xpath.objects.XString
> > > >         at
> > > > org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2416)
> > > >         at
> > > > org.apache.xalan.templates.ElemTemplate.execute(ElemTemplate.java:392)
> > > >         at
> > > > org.apache.xalan.templates.ElemCallTemplate.execute(ElemCallTemplate.java:246)
> > > >         at
> > > > org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2411)
> > > > 
> > > > I wrote a new siteinfo-meta contract and thought it is because of the
> > > > contract, but I then tried our feeder contract and that is not working
> > > > either.
> > > > 
> > > > I am debugging that now if somebody has an idea what is going on or
> > > > which recent changes are may the cause, please, speak up. ;-)
> > > > 
> > > > salu2
> > > > --
> > > > thorsten
> > > > 
> > > > "Together we stand, divided we fall!"
> > > > Hey you (Pink Floyd)
> > > > 
> > > >
-- 
thorsten

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