0

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"/>
</xsl:attribute>
Click Here to see the Announcement
</xsl:element> 

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.

0

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>
</xsl:if> 

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.