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

Re: testing for existence of variables?

Subject: Re: testing for existence of variables?
From: Jeni Tennison <Jeni.Tennison@xxxxxxxxxxxxxxxx>
Date: Wed, 21 Jun 2000 10:17:32 +0100
xsl tester existence variable

>What I want to know is, can I check for the existence of the <user> 
>information and display some HTML if it exists, and otherwise present 
>alternate HTML? Or should this check be done on the server side in the 
>scripting layer instead?

You can do this within an XSLT stylesheet.  There are a couple of elements
that enable you to conditionally construct results:

  <xsl:if test="condition">
    result if the condition is true


    <xsl:when test="condition1">
      result if condition1 is true
    <xsl:when test="condition2">
      result if condition2 is true
      result if no conditions are true

So, in your case, you want to test if the XML document contains a 'user'
element, to output one set of HTML if it is, and another if it isn't:

    <xsl:when test="//user">
      content for known users
      content for unknown users

Note: I don't know where in your XML document this 'user' element appears,
and it would be better if you can construct a direct path to it, to save
the XSLT processor having to search every descendent of the root node.

I hope this helps,


Dr Jeni Tennison
Epistemics Ltd, Strelley Hall, Nottingham, NG8 6PE
Telephone 0115 9061301 ? Fax 0115 9061304 ? Email

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

Current Thread


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.
First Name
Last Name
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.