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

Re: Testing if an element has an attribute

Subject: Re: Testing if an element has an attribute
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 8 Oct 2001 17:59:54 +0100
Re:  Testing if an element has an attribute
an XSL stylesheet has to be XML

 <xsl:if @name != "">           

isn't XML: you can only have attribute/value pairs inside the element
start tag.

You could change it to

 <xsl:if test="@name != ''">   

and then it would be legal. However it doesn't do what the subject line
suggests, it tests whether the attribute is non empty.

In particular

<person name=""/>

has a name attribute but the above test would be true.

If you want to test if person has an attribute just do

<xsl:if test="@person">

however since you use the person attribute as an element name, I suspect
that your first test is better.

Also of course you have these lines in the wrong order

  </xsl:if>
 </xsl:element>

you need to close the xsl:element inside the xsl:if since you started
it inside th exsl:if.

David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

 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.