xsl-list
[Top] [All Lists]

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

2011-11-30 15:06:20

One question.

 

As I understand this right, I have to put the display of the articles in 
printdata. 

 

Roelof



----------------------------------------
From: jwilkinson(_at_)tsystem(_dot_)com
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Date: Wed, 30 Nov 2011 12:40:55 -0600
Subject: RE: [xsl] can a value of a parameter depends on a other value

Perhaps something more like this:

<!-- Named template definition: printdata -->
<xsl:template name="printdata">
<xsl:param name="articleperpage"/> <!-- parameter declaration -->

<!-- Template logic -->

</xsl:template>

<xsl:call-template name="printdata">
<xsl:with-param name="articleperpage"> <!-- parameter value to pass to named 
template -->
<xsl:choose>
<xsl:when test="($month = '2005-02') and (number($page) = 1)">2</xsl:when>
<xsl:when test="($month = '2005-02') and (number($page) = 2)">3</xsl:when>
<otherwise>1</otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>


John

-----Original Message-----
From: Roelof Wobben [mailto:rwobben(_at_)hotmail(_dot_)com]
Sent: Wednesday, November 30, 2011 12:19 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] can a value of a parameter depends on a other value


Thanks,



I wonder if this is right.



<xsl:param name="articleperpage"/ >

<xsl:call-template name="printdata">

<xsl:choose>

<xsl:when test="($month = '2005-02') and (number($page) = 1)">

<xsl:with-param name="articleperpage" select="1" />
</xsl:when>

</xsl:choose>

</xsl:call-template>



Or something like this idea ?



Roelof







From: jwilkinson(_at_)tsystem(_dot_)com
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Date: Wed, 30 Nov 2011 11:30:15 -0600
Subject: RE: [xsl] can a value of a parameter depends on a other value

That's a lot clearer. Below is an XSLT 1.0 stylesheet that (I think) does 
what you want. The stylesheet itself just copies the input through to the 
output, recursing through all elements and explicitly copying whatever it 
finds. It could be improved in XSLT 2.0 (probably even in 1.0), but it is 
what I have handy.

John

=============================================================

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="http://tsystem.com/ev2";>
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"
encoding="Windows-1252"/>

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

<!-- For later use -->
<xsl:param name="totalpages"/>
<xsl:param name="offset"/>


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

<!-- Using the variable -->
<xsl:template name="EmitArticles">
<xsl:choose>
<xsl:when test="number($articlesperpage) = 3">
<!-- Emit three articles. -->
</xsl:when>
<xsl:when test="number($articlesperpage) = 2">
<!-- Emit two articles. -->
</xsl:when>
<!-- Emit one article? -->
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="/">
<xsl:copy>
<xsl:apply-templates select="* | @* | comment()"/> </xsl:copy>
</xsl:template>

<xsl:template match="@*">
<xsl:copy-of select="."/>
</xsl:template>

<!-- Remove the Stylus Studio metadata, if it is present. -->
<xsl:template match="comment()[contains (.,'Stylus Studio
meta-information')]"> </xsl:template>

<xsl:template match="comment()">
<xsl:copy-of select="."/>
</xsl:template>

<xsl:template match="*">
<xsl:choose>
<xsl:when test="./*">
<xsl:copy>
<xsl:apply-templates select="* | @* | comment()"/> </xsl:copy>
</xsl:when> <xsl:otherwise> <xsl:copy-of select="."/> </xsl:otherwise>
</xsl:choose> </xsl:template>

</xsl:stylesheet>

========================================================

-----Original Message-----
From: Roelof Wobben [mailto:rwobben(_at_)hotmail(_dot_)com]
Sent: Wednesday, November 30, 2011 11:09 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] can a value of a parameter depends on a other value



What am trying to make is a blog which dived into months.

Some months have so many articles that I have to divide them into pages.

The problem is that I want to decide how many articles are placed on a 
particular place.



So i want to make a parameter articlesperpage which value depends on the 
value of the parameters month and page.

The parameters month and page are made by the cms I use. That's Symphony 
cms.



So in pseudoocode I want this.



If month="2005-02" and page=1 then articlesperpage must be 2

if month="2005-02" and page=2 then articlesperpage must be 3



Later on I also need the parameters totalpages and offset.

Totalpages is the total of pages of a month. I need it because later on I 
will write a prev/next script.

Offset is the number of articles which must not be displayed because the 
articles are displayed on a earlier page.



But first I want to make it work with one parameter and I try to find out 
how to make this work.



Roelof






----------------------------------------
Date: Wed, 30 Nov 2011 14:10:10 +0000
From: mike(_at_)saxonica(_dot_)com
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] can a value of a parameter depends on a other
value

On 30/11/2011 11:02, Roelof Wobben wrote:
Oke,





The whole xslt looks like this :




I hope I now give enought clues to solve this.



We can now see exactly what's wrong, but we can't help you to fix
it, because we have no idea what you are trying to achieve.

Michael Kay
Saxonica

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

This e-mail message and any attachment(s) transmitted with it are
intended only for the use of the recipient(s) named above.This message may 
be privileged and/or confidential.
If you are not an intended recipient, you may not review, copy or 
distribute this message.
If you have received this communication in error, please notify us
immediately by e-mail and delete the original message.



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

This e-mail message and any attachment(s) transmitted with it are intended 
only for the
use of the recipient(s) named above.This message may be privileged and/or 
confidential.
If you are not an intended recipient, you may not review, copy or distribute 
this message.
If you have received this communication in error, please notify us 
immediately by e-mail
and delete the original message.



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