I am creating a link on a custom display form in SP2013 on premise.

I can create a working link fine using:

<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="@Announcement"/>
Click Here to see the Announcement

However as the link can sometimes not exist how do I check if @Announcement is empty and thus do not display the link?

ps. I have tried implementing this: How to check if variable is not empty in xslt? however I have not been successful.

1 Answer 1


You've used three terms as if they were synonyms:

  • is null

  • does not exist

  • is empty

In XML, there's no such thing as "null". An attribute can be absent, or it can be empty, and these are different things. So you need to be much more clear in your requirements.

If you want to create the "a" element if and only if there is a non-empty @Announcement attribute, try:

<xsl:if test="string(@Announcement)">
  <a href="{@Announcement}">Click here...</a>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.