xsl-list
[Top] [All Lists]

Re: [xsl] Template mode value from param

2011-09-21 08:42:03
Hey all,

by looking at this situation from another angle I realized that we
actually have sioc:Forum elements that can be used for match in the
intermediary layout template instead rdf:RDF. So now it looks like
this:

default.xsl

<section id="content">
  <xsl:apply-templates/>
</section>

comic_strips.xsl:

<xsl:template match="sioc:Forum[contains(@rdf:about, 'striben')] |
*[rdf:type/@rdf:resource = '&sioc;Forum'][contains(@rdf:about,
'striben')]">
  <xsl:apply-templates select="key('resources-by-type', '&hn;StripPost')"/>
    <div>
      <!-- some content/navigation here -->
    </div>
</xsl:template>

Much more simple and generic - and it works :)

On Wed, Sep 21, 2011 at 3:09 PM, Andrew Welch 
<andrew(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com> wrote:
 <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>
--~--



--~------------------------------------------------------------------
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>