[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Template mode value from param

Subject: Re: Template mode value from param
From: Martynas Jusevicius <martynas.jusevicius@xxxxxxxxx>
Date: Wed, 21 Sep 2011 15:41:51 +0200
Re:  Template mode value from param
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.j.welch@xxxxxxxxx>
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.