xsl-list
[Top] [All Lists]

Re: [xsl] Template mode value from param

2011-09-21 08:09:47
 <xsl:import href="comic_strips.xsl"/>
 <xsl:param name="view"/>

 <xsl:template match="/">
   <html>
     <head>...</head>
     <body>
       <!-- header goes here -->
       <!-- insert main content here -->
       <section id="content">
         <xsl:choose>
           <xsl:when test="$view = '&hn;FrontPageView'">
             <xsl:apply-templates select="rdf:RDF" mode="hn:FrontPageView"/>
           </xsl:when>
           <!-- more cases here -->

At somepoint you will need the logic to based on the $view param, so
you can either do it like you have, or create a new entry point
stylesheet called FrontPageView.xslt that just applies templates in
that mode, and move the logic into whatever is calling the transform
to use the new entry point.

To do that you need to rewrite your existing template a little to
accept the mode and pass it on (using #all and #current):

 <xsl:template match="/rdf:RDF" mode="#all">
   <html>
     <head>...</head>
     <body>
       <!-- header goes here -->
       <!-- insert main content here -->
       <section id="content">
         <xsl:choose>
           <xsl:when test="$view = '&hn;FrontPageView'">
             <xsl:apply-templates select="." mode="#current"/>

and then in the new entry point stylesheet:

<xsl:template match="/">
  <xsl:apply-templates select="rdf:RDF" mode="hn:FrontPageView"/>
</



-- 
Andrew Welch
http://andrewjwelch.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>