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

Re: xsl:if with params

Subject: Re: xsl:if with params
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 24 Sep 2004 15:12:40 +0100
xpath with params
  So, when i'm making

        <xsl:if test="$main">

  what am i saying in english?

You are saying if the boolean value of $main is true() then do something.


What probably is confusing you is that pretty much everything in Xpath
has a boolean value. Or to put it another way, will silently be coerced
to boolean if it has another type.

Node sets are true() if they are non-empty,

  <xsl:param name="main" select="somevalue"/>

so that has set the default value of $main to be the node set selected
by the xpath somevalue when the current node is the root  of the
document. So if somevalue is not the name of the top level element, this
is an empty node set so $main will act as false() in a boolean test.



    stylesheet.setParameter("main", "ok");

here you have set $main to be the string "OK" strings are coerced to
true() if they are non empty and false() if they are "" so "ok" like any
non empty string will test as true()

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.