forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <>
Subject RE: Re: voice stylesheet and views
Date Fri, 23 Sep 2005 23:17:46 GMT
El vie, 23-09-2005 a las 17:15 +0200, HANAX escribió:
> > HANAX wrote:
> > > As I understood, contracts are points where to place xsl templates.
> >  
> > Yes, templates, but not complete stylesheets...
> Ok, then how to import some namespace? My namespace is "vxml" but now it's ignored...

What do you mean by ignored?

You need to follow the basic rules of xsl/xml in the contract!

So you just define:
<forrest:contract name="nav-section" type="nugget"

Then you can do whatever you want:


<xsl:value-of select="vxml:element" />

> >  
> > > I noticed some some structure naming convention but I can't find where it's
> >  
> > Because they are not, at least not in an easily accessible way. There 
> > will be discussion in the mail archives, but they are not documented 
> > anywhere. I'm afraid I can't tell you what they are.
> >  
> > > Now my problem:
> > > 1. Originally I had my template for generating "voice head"
> > > 2. I have contract voice-markup.ft 
> > > 3. I added my original voice stylesheet template under some forrest:template
node in contract and rename it to voice-markup-head
> > > 4. No results :(
> >  
> > What do you mean "no result", do you get any output at all?
> As no result I mean:
> I have:
>   <xsl:template name="voice-markup-head">
>     <xsl:apply-templates select="//document"/>
>   </xsl:template>
>   <xsl:template match="document">
>     <xsl:apply-templates select="//body"/>
>   </xsl:template>
>   <xsl:template match="body">
>     <xsl:call-template name="voiceNavigation"/>
>   </xsl:template>
>   <xsl:template name="voiceNavigation">
>     ...
>   </xsl:template>
> but nothing in header in result page...

I need to see the part coming before that to say something about that.

I need to see something like:
  format="xhtml" name="voice-markup" inputFormat="xsl" body="false" head="true"/>

Anyway a good thing to do to debug a contract is to:
<xsl:template name="voice-markup-head">
  xXx <xsl:apply-templates select="//document"/>

If you can find "xXx" in the output that means that the contract is
reached but the xsl is not right. 

* Check whether your matches are working by adding debugging string like
"xXx", "zZz", ... Then you see which point of the stylesheet is failing.
* Check whether all variables get parsed the right way. The contract
variables are not global and have to be passed along the xsl templates.
* Check whether all input variables are passed in from the view (see
* ...

BTW to make it just a wee bit more complicated ;-) we introduced
something like:
-in your view-
<forrest:contract name="nav-section">
  <forrest:properties contract="nav-section">
    <forrest:property name="nav-section" nugget="get.navigation">

Where #{$cocoon/parameters/getRequest}.navigation.xml is a jx-path
expression [1] for the requested document. Let me give you an example.
Requesting e.g.:

Will be matched (by the view processing [2]) like:
<map:match pattern="prepare.view.**">
  <map:generate type="jx" src="cocoon:/prepare.jxWorkaround.{1}">
    <map:parameter name="lenient-xpath" value="true"/>
    <map:parameter name="getRequest" value="{1}"/>

for geting the right view and 

<map:match pattern="prepare.view-nugget.**">
  <map:generate src="cocoon:/prepare.view.{1}">
    <map:parameter name="lenient-xpath" value="true"/>
    <map:parameter name="getRequest" value="{1}"/>
  <map:transform src="resources/stylesheets/prepare.view.xsl">
    <map:parameter name="view" value="{1}"/>
  <map:transform type="xinclude"/>

For including the requested data model that the contract has to transform.

where {1} is in our example "index" (notice 
the strip of the extension). That means that 
will be resolved to index.navigation.xml. 

The nugget contracts are including any source that can be resolved 
through a sitmap. We transform index.navigation.xml to 
and include this in the view.

In our case [2]:
<!-- navigation for the current request -->
<map:match pattern="*.navigation.xml">
  <map:aggregate element="navigation">
    <map:part src="cocoon:/tab-{1}.html" element="tab"/>
    <map:part src="cocoon:/menu-{1}.html" element="menu"/>

Now in our <forrest:contract name="nav-section"/> [3]
we start the processing like:
<xsl:template name="nav-section-body">
  <xsl:param name="nav-section" select="'test'"/>
    |start menu
  <xsl:if test="$nav-section/navigation/menu/div[@id='menu']/ul/li">
    <xsl:call-template name="menu">
      <xsl:with-param name="root" select="$nav-section/navigation/menu"/>
    |end menu

That means we resolve index.navigation.xml and use it in our processing like:

That is just a xpath expression for the incoming xml stored in 
<xsl:param name="nav-section"/>.

Requested by the view and passed to the contract via:
<forrest:property name="nav-section" nugget="get.navigation">

>>From there you can do anything like you wrote above.

You *should* choose unique naming of the templates to 
prevent clashing of them. If the xslt processor find two 
template with the same name you will get an error.

Further you have to consider that 
<xsl:template name="voice-markup-head">
  <xsl:apply-templates select="//document"/>
will match *any* occurrence of the document element - even if they 
included by another nugget-contract. 

If you understood the above written you should do something like:
<xsl:template name="voice-markup-head">
  <xsl:apply-templates select="$voice-markup/document">
    <xsl:with-param name="$voice-markup"

> Anyway, why it must be named "voice-markup-head"?

Because ATM we call in [4]
    <alias:call-template name="getHead"/>
  <body onload="init()">
    <alias:call-template name="getBody"/>

The "my trip through the view-related pipelines" thread started by tim
williams has more on that. He calls the part "where the magic happens"
and he is right. ;-)






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

View raw message