XSL if ContentType has a given value

I am trying to determine content type of the item. I tried this but I think ContentType in results.aspx webpart is known with another name.

<xsl:if contenttype="mycustomcontenttype"> 
 <xsl:Value-of select="contenttype" />
<xsl:if>

Answers


Your XSLT is badly formatted.

There is no such xsl:if attribute called contenttype - nor is there an <xsl:Value-of because all instructions are case-sensitive, and should be in lower case.

Your code should be something like this...

<xsl:if test="contenttype='mycustomcontenttype'"> 
 <xsl:value-of select="contenttype" />
<xsl:if>

Or even this one-liner (no conditionals used at all):

<xsl:value-of select="contenttype[.='mycustomcontenttype']"/>

Need Your Help

Help to convert PostgreSQL dates into SQL Server dates

sql-server regex datetime

Hello I'm doing some data conversion from PostgreSQL to Microsoft SQL Server. So far it has all went well and I almost have the entire database dump script running. There is only one thing that is ...

AJAX not rendering partial

javascript jquery html ruby-on-rails ajax

I have a view called events\new.html.erbwhich holds a collection select of other users. I want to make it so that every time the user selects a different name in the collection select, a &lt;div id="