This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]