Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Testing Whether An Element Exists Or Has Value [Thread Next] Re: Testing Whether An Element Exists Or Has ValueTo: NULL Date: 5/9/2005 10:13:00 AM "MDW" <MDW@d...> wrote in message news:A3B198F8-333D-4AE7-B17C-29CA672E3018@m...... > Hey all, > > I'm just starting out with XML/XSL, so I apologize if this is a stupid > question. I'm working on formatting some XML documents for display on the Web > (I doubt there will be any other use of them for any other application). > > I'm creating several documents that will have a CreatedDate element. Also, > if there has been a change since the doc was created, there may also be a > LastModified element. On the Web page, I want to display something like this: > > "Created: 12/23/2003 > Last Modified: 04/27/2004" > > but obviously, if something hasn't been modified, I don't want to display > that second line. How, in XSL, can I test whether the LastModified element is > there? (It also may be there, but be empty.) > > Thanks. > -- > Hmm...they have the Internet on COMPUTERS now! <xsl:if test="LastModified != ''"> <!-- do something --> </xsl:if> You may need to modify the XPath to match your context node. If you just want to test if the element exists at all use: test="LastModified". http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/conXSLT.asp?frame=true -- Joe (MVP - XML) https://mvp.support.microsoft.com/profile=8AA9D5F5-E1C2-44C7-BCE8-8741D22D17A5 | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
