This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: IF-ELSE.. Sorting


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@iafrica.com [SMTP:pcaspian@iafrica.com]
Verzonden:	maandag 18 juni 2001 13:16
Aan:	xsl-list@lists.mulberrytech.com
Onderwerp:	[xsl] 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]