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

RE: can a value of a parameter depends on a other valu

Subject: RE: can a value of a parameter depends on a other value
From: John Wilkinson <jwilkinson@xxxxxxxxxxx>
Date: Wed, 30 Nov 2011 12:40:55 -0600
RE:  can a value of a parameter depends on a other valu
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@xxxxxxxxxxx]
Sent: Wednesday, November 30, 2011 12:19 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  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@xxxxxxxxxxx
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Date: Wed, 30 Nov 2011 11:30:15 -0600
> Subject: RE:  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@xxxxxxxxxxx]
> Sent: Wednesday, November 30, 2011 11:09 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  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@xxxxxxxxxxxx
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: Re:  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
>
> 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.

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.

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.