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

RE: problem with xsl:choose

Subject: RE: problem with xsl:choose
From: "Student1 ASCO-ELK (RBJE/ELK)" <Student1.ASCO-ELK@xxxxxxxxxxxx>
Date: Fri, 25 May 2001 10:27:49 +0200
xsl when select
thx for the info.

i cant use the <xsl:apply-templates .../>
because of the 'FOOBARs' and 'BLABLABLAs' ;)
i dont want them to be seen in the final document

xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
  <xsl:template match='/'>
     <xsl:choose>
       <xsl:when select='//screen'>
         FOOBAR
         ....call template
         FOOBAR
       </xsl:when>
       <xsl:when select='//table'>
         BLABLABLA
         ....call template
         BLABLABLA
       </xsl:when>
       <xsl:otherwise>
         ....
       </xsl:otherwise>
     </xsl:choose>
  </xsl:template>
...
</xsl:stylsheet>

so i have to do a test for the nodename, but how ?
cu goose

-----Original Message-----
From: Gavin Corfield [mailto:gavin@xxxxxxxxxxxxxxxxxx]
Sent: Friday, May 25, 2001 4:58 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  problem with xsl:choose


"Student1 ASCO-ELK (RBJE/ELK)" wrote:
> 
You are misusing the <xsl:choose> statement and syntax is:

<xsl:choose>
	<xsl:when test="some expression">

	</xsl:when>
		etc
	<xsl:otherwise>
	</xsl:otherwise>
</xsl:choose>

when the test statement evaluates to true then the following commands
are accessed.  In your case as screen exists true is returned (though
syntax is wrong) and the nodes are processed.  

but that isn't what you want to use anyway:	

you need something like:

<xsl:template match="/">
	<xsl:apply-templates select="//screen" />
	<xsl:apply-templates select="//table" />
</xsl:template>

etc.

gavin

> hi all,
> 
> i have a little problem with the xsl:choose, because it stops if
> a match has been found. not like the c style switch statement - which
needs
> a explicit BREAK to stop!
> 
> my xml looks like this:
> <data>
>   <screen h=3 w=5 />
>   <screen h=5 w=6 />
>   <table h=2 w=2 />
>   <table h=6 w=8 />
>   <table h=1 w=9 />
> </data>
> 
> my xsl like this:
> <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
>   <xsl:template match='/'>
>      <xsl:choose>
>        <xsl:when select='//screen'>
>          ....call template
>        </xsl:when>
>        <xsl:when select='//table'>
>          ....call template
>        </xsl:when>
>        <xsl:otherwise>
>          ....
>        </xsl:otherwise>
>      </xsl:choose>
>   </xsl:stylesheet>
> ...
> </xsl:stylsheet>
> 
> but unfortunately this one exits, after having processed all screens
> any suggestions ?
> thx in advance
> 
> cu goose
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 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.