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

RE: IF-ELSE.. Sorting

Subject: RE: IF-ELSE.. Sorting
From: Rene de Vries <RdVries@xxxxxxxxxxx>
Date: Mon, 18 Jun 2001 14:26:55 +0200
xsl if else
Hi Karlo,

As you may already have read in your XSLT-book: there is no 
IF-ELSE-construction, just use:
<xsl:choose>
	<xsl:when test="...">
		...
	</xsl:when>
	<xsl:otherwise>
		...
	</xsl:otherwise>
</xsl:choose>

furtermore the message "Keyword xsl:sort may not be used here. " you get is 
because <xsl:sort...> must be the first element (child) within 
<xsl:for-each...> and <xsl:apply-templates....>.
And that gives you a new problem, because an <xsl:choose> is not allowed 
before the <xsl:sort...>
I think you have to fill a parameter and pass it to a template which will 
do the for-each and the sort.

Greetings Rene
   { @   @ }
        ^
      \__/

"You don't need eyes to see, you need vision!"

-----Oorspronkelijk bericht-----
Van:	pcaspian@xxxxxxxxxxx [SMTP:pcaspian@xxxxxxxxxxx]
Verzonden:	maandag 18 juni 2001 13:16
Aan:	xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Onderwerp:	 IF-ELSE.. Sorting

<xsl:for-each select="LIST/ASSIGN">


* Hi, I am trying to do a conditional sort. I want to have a look at an
input parameter $arrangeby and if this is of Type DATE then I would like to
specify a sorting different from my usual

<xsl:sort select="*[name()=$arrangeby]"/>

as now I want to specify the data-type as "number" and then also break it
up into
substring-before and substring-after, I will want to specify a different
<xsl:sort>, so
I assumed I would use <xsl:if test="$arrangeby = 'DATE'"> and put in my xsl
code and finish it off
with </xsl:if>.

To start off with, quite basically, I need to know precisely how the
if-else syntax works. Hehhe, just cant find an If-Else example.
Secondly if I use this basic IF check...

      <xsl:for-each select="LIST/ASSIGN">

      <xsl:if test="$arrangeby = 'TSDATE'">
		<xsl:message>
		Hello
		</xsl:message>
      </xsl:if>
               	
	  <xsl:sort select="*[name()=$arrangeby]"/>


I get the error "Keyword xsl:sort may not be used here. "


The  <xsl:if>..</xsl:if>  block works fine when place just before the
<xsl:for-each> block.

**finally got my XSLT book, so hopefully I will ask less daft questions in
the future. Thanks for all those that have managed to just "grin and bare"
my simple questions so far ;)

Karlo





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.