xsl-list
[Top] [All Lists]

RE: [xsl] can a value of a parameter depends on a other value

2011-12-02 05:34:26

Oke, 

 

I made a quick draft of the idea I have to solve my problem and you can see I 
need all those variables 



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:output method="xml"
 doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";
 omit-xml-declaration="yes"
 encoding="UTF-8"
 indent="yes" />

 

 

<xsl:param name="page" />

<xsl:param name="month""/>


<xsl:variable name="articlesperpage">
<xsl:choose>
<xsl:when test="$page='1' and $month='2005-02' ">3</xsl:when>
<xsl:otherwise>2</xsl:otherwise>
</xsl:choose>
</xsl:variable>

 

<xsl:variable name="totpages">
<xsl:choose>
<xsl:when test=" $month='2005-02">2</xsl:when>
<xsl:otherwise>2</xsl:otherwise>
</xsl:choose>
</xsl:variable>

 

<xsl:variable name="offset">
<xsl:choose>
<xsl:when test=" $page=1 $month='2005-02">0</xsl:when>
<xsl:otherwise>3</xsl:otherwise>
</xsl:choose>
</xsl:variable>

 

 

<xsl:template match="/">
  <xsl:apply-templates select="/data/test/entry"/>

  <xsl:apply-templates select="besturing" />
</xsl:template>


<xsl:template match="/">
<xsl:template match="/">
<xsl:if (position()>='offset' and postition() >= 'offset+articlesperpage') >

<h1><xsl:value-of select="titel"/></h1><br />
    <xsl:value-of select="datum" /><br />
    <xsl:value-of select="tekst" /> <br />
</xsl:if>

</xsl:template>

 

<xsl:template match="besturing">
 <xsl:if test="$Page &gt; 1 and
          $Page &lt; $totalPages"> ↔ </xsl:if>
      <xsl:if test="$Page &lt; $totalPages">
      <!-- here the links for next

      /xsl:if>
      <xsl:when test="$Page eq 2">
           <!-- here the links for the previous 

</xsl:template


 

</xsl:stylesheet>

 

 

 

 

----------------------------------------
Date: Fri, 2 Dec 2011 09:18:14 +0000
From: davidc(_at_)nag(_dot_)co(_dot_)uk
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
CC: rwobben(_at_)hotmail(_dot_)com
Subject: Re: [xsl] can a value of a parameter depends on a other value

On 02/12/2011 08:02, Roelof Wobben wrote:
<xsl:when test="$page='1'">number(1+$page*2)</xsl:when>

the content of xsl:when is like the content of any other part of the
template just copied to the output as text or literal result elements.
If you want to evaluate an xpath you need to put it in a select
expression, in a xsl:value-of most likely, in XSLT 1

<xsl:when test="$page='1'"><xsl:value-of select="1+$page*2"/></xsl:when>

There is still no evidence that you actually need any variables at all.
Do you really need to pass any parameter to your template? the $page
parameter is in scope for the entire stylesheet so you could just use
1+$page*2 at whatever point you need that number, and avoid all the
complication.

David

--
google plus: https:/profiles.google.com/d.p.carlisle

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________      
                                  

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