Ufff...
A bit complicated for me :(
Anyway I understood some parts, but still I'll rather to solve previous problem:
Now more details:

In view I have
<forrest:contract name="voice-markup"/>

In contract

<forrest:template
  xmlns:forrest="http://apache.org/forrest/templates/1.0";
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:vxml="http://www.w3.org/2001/vxml";
  xmlns:ev="http://www.w3.org/2001/xml-events";
  xmlns:xv="http://www.voicexml.org/2002/xhtml+voice";
  xml:lang="en-US"
  format="xhtml" name="voice-markup" inputFormat="xsl" body="false" head="true">

  <xsl:stylesheet>
    <xsl:template name="voiceNavigation"/>

    <xsl:template name="voice-markup-head">
      XXX
      <xsl:apply-templates select="//document"/>
    </xsl:template>

    <xsl:template match="document">
      YYY
      <xsl:apply-templates select="//body"/>
    </xsl:template>

    <xsl:template match="body">
      zzz
      <xsl:call-template name="voiceNavigation"/>
    </xsl:template>

  </xsl:stylesheet>
</forrest:template>

but anything I got is XXX... Nothing more. Can you find out why?

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

Now I really don't understand... If I use <xsl:apply-templates 
select="//document"/>, I need to process all document nodes. I expected that 
I'm working with xdoc source document, didn't I? So I thought taht every 
contract has as it's input same xdoc... I thought that I finally have idea how 
contracts works but seems that I haven't :(
All I need is to duplicate all visual structures of document into their's audio 
equvalents. So for every section in body I need to make voice section in head. 
So I think I process whole document, not only part... but maybe I'm thinking in 
bad way...

______________________________________________________________________
PÔVODNÁ SPRÁVA
Od: "Thorsten Scherler" <[EMAIL PROTECTED]>
Pre: dev@forrest.apache.org
Predmet: RE: Re: voice stylesheet and views
Dátum/Čas: 24. 9. 2005 1:17:46

> 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"
>   xmlns:forrest="http://apache.org/forrest/templates/1.0";
>   xmlns:vxml="http://url/to/vxml/namespace";>
>
> Then you can do whatever you want:
> <vxml:element>something</vxml:element>
>
> or
>
> <xsl:value-of select="vxml:element" />
>
> > >
> > > > I noticed some some structure naming convention but I can't find where 
> > > > it's explained.
> > >
> > > 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:
> <forrest:template
>   xmlns:forrest="http://apache.org/forrest/templates/1.0";
>   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"/>
> </xsl:template>
>
> 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
> above).
> * ...
>
> 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">
>       <url>#{$cocoon/parameters/getRequest}.navigation.xml</url>
>     </forrest:property>
>   </forrest:properties>
> </forrest:contract>
>
> 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.:
> http://localhost:8888/index.html
>
> 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}"/>
>   </map:generate>
>   <map:serialize/>
> </map:match>
>
> 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:generate>
>   <map:transform src="resources/stylesheets/prepare.view.xsl">
>     <map:parameter name="view" value="{1}"/>
>   </map:transform>
>   <map:transform type="xinclude"/>
>   <map:serialize/>
> </map:match>
>
> 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
> #{$cocoon/parameters/getRequest}.navigation.xml
> 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
> cocoon://index.navigation.xml
> 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"/>
>   </map:aggregate>
>   <map:serialize/>
> </map:match>
>
> 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'"/>
> <xsl:comment>+
>     |start menu
>     +</xsl:comment>
>   <xsl:if test="$nav-section/navigation/menu/[EMAIL PROTECTED]'menu']/ul/li">
>     <xsl:call-template name="menu">
>       <xsl:with-param name="root" select="$nav-section/navigation/menu"/>
>     </xsl:call-template>
>   </xsl:if>
> <xsl:comment>+
>     |end menu
>     +</xsl:comment>
> </xsl:template>
>
> That means we resolve index.navigation.xml and use it in our processing like:
> $nav-section/navigation/menu
>
> 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">
>   <url>#{$cocoon/parameters/getRequest}.navigation.xml</url>
> </forrest:property>
>
> >From there you can do anything like you wrote above.
>
> WARNING:
> 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.
>
> WARNING:
> Further you have to consider that
> <xsl:template name="voice-markup-head">
>   <xsl:apply-templates select="//document"/>
> </xsl:template>
> 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"
>       select="$nav-section/document"/>
>   </xsl:apply-templates>
> </xsl:template>
>
>
> > Anyway, why it must be named "voice-markup-head"?
>
> Because ATM we call in [4]
> <html>
>   <head>
>     <alias:call-template name="getHead"/>
> ...
>   </head>
>   <body onload="init()">
>     <alias:call-template name="getBody"/>
>
> ...
>   </body>
> </html>
>
> 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. ;-)
>
> HTH
>
> salu2
>
> [1]
> http://cocoon.apache.org/2.1/userdocs/flow/jxtemplate.html
>
> [2]
> http://svn.apache.org/viewcvs.cgi/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.view/internal.xmap?view=markup
>
> [3]
> http://svn.apache.org/viewcvs.cgi/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.viewHelper.xhtml/resources/templates/nav-section.ft?view=markup
> [4]
> http://svn.apache.org/viewcvs.cgi/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.view/resources/stylesheets/prepare.xhtml.xsl?view=markup
> --
> thorsten
>
> "Together we stand, divided we fall!"
> Hey you (Pink Floyd)
>
>

Reply via email to