HANAX wrote:
That's true, I really need to start with small steps.
So here ve are:
Expecting document in format you described:
 <document>
    <header>
      <title>My Document</title>
    <header>
    <body>
      <section>
        <title>Section 1</title>
        ...
        <section>
          <title>Section 1.1</title>
          ...
        </section>
        ...
      </section>
<section>
        <title>Section 2</title>
        ...
      </section>
    </body>
 </document>

Now what I need:
<head> <title>The title</title>
  <vxml:form>
    <vxml:field name="section1">
       ...
    </vxml:field>
    <vxml:field name="section1_1">
       ...
    </vxml:field>
    <vxml:field name="section1_2">
       ...
    </vxml:field>
  </vxml:form>
</head>
How this should be done? Using xsl?

Yes, using XSL

Currently I have:

  <map:pipelines>
    <map:pipeline>
      <!-- Voice -->
      <map:match type="regexp" pattern="^(.*?)([^/]*).mxml$">
        <map:aggregate element="site">
          <map:part src="cocoon://{1}{2}.xml"/>
        </map:aggregate>
        <map:transform src="resources/stylesheets/document2mxml.xsl"/>
        <map:serialize type="xhtml"/>
      </map:match>
    </map:pipeline>
  </map:pipelines>

You have this in your output.xmap of the plugin, right?

This looks fine, now in your document2mxml.xsl you need

<xsl:template name="voiceNavigation">
  <vxml:form>
  <xsl:for-each select="//section">
       <vxml:field>
         <xsl:attribute name="name">
           <xsl:value-of select="title"/>
         </xsl:attribute>
         ...
       </vsml:field>
  </xsl:for-each>
  </vxml:form>
</xsl:tempalte>

To call the template at the relevant point in your stylesheet you need:

<xsl:apply-tempalte name="voiceNavigation"/>

Once we have this basic stuff working we can work with Thorsten getting it into a template for views.

NOTE
The map:aggregate is not needed since you are not aggregating any documents. Just use <map:generate src="cocoon://{1}{2}.xml"/>, this will make the root element of your input to the transformation <document>, so you will need to change your XSL accordingly.


What about serialization? I need output in xhml, what <map:serialize 
type="xhtml"/> element really does?

See http://cocoon.apache.org/2.1/userdocs/serializers/xhtml-serializer.html

Ross

Reply via email to