This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Testing if an element has an attribute
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] Testing if an element has an attribute
- From: David Carlisle <davidc at nag dot co dot uk>
- Date: Mon, 8 Oct 2001 17:59:54 +0100
- References: <OFD3F679F0.144B72DA-ON80256ADF.005AD4F7@nebula.ie>
- Reply-To: xsl-list at lists dot mulberrytech dot com
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