This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: making html output for application pages


Bernie Bernstein wrote:
> When generating the pages, the xsl figures out the general layout of the
> page and values of things like the page title, headers. This requires lots
> of instances of:
> 
> <xsl:choose>
>   <xsl:when test='/top/page = "index"'>
>     <xsl:text>This is the index page</xsl:text>
>   </xsl:when>
>   <xsl:when test='/top/page = "somePage"'>
>     <xsl:text>This is some other page</xsl:text>
>   </xsl:when>
>   ... and so on for about 30 pages ...
> </xsl:choose>

Well, you can try to leverage the template mechanism.
For example
  <xsl:template match="top">
   <html>
    <head>
     <title>
       <xsl:apply-template select="page" mode="title"/>
     </title>
    </head>
    <body>
       <xsl:apply-template select="page" mode="body"/>
    </body>
   </html>
  </xsl:template>

  <xsl:template match="page[.='index']" mode="title">
    <xsl:text>Index page</xsl:text>
  </xsl:template>

  <xsl:template match="page[.='somePage']" mode="title">
    <xsl:text>This is some other page</xsl:text>
  </xsl:template>

I hope you see the pattern and can extend on it.

J.Pietschmann


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]