Umbraco XSLT Attributes must come immediately after the enclosing tag

written by the admin on Tuesday, November 04 2008

Just spent a frustrating 2 hours trying to get this to work to highlight a specific navigation element

  <a href="{umbraco.library:NiceUrl(@id)}">
   <xsl:value-of select="@nodeName"/>
<xsl:if test="$currentPage/ancestor-or-self::node/@id=@id">
<xsl:attribute name="class">selected</xsl:attribute>
</xsl:if>
</a>

It gives an XSLT error when trying to save because the attribute statement is after the content of the tag (the <xsl:value-of select="@nodeName"/>), by putting hte attribute clause before the content, this fixes the error as follows:

  <a href="{umbraco.library:NiceUrl(@id)}">
<xsl:if test="$currentPage/ancestor-or-self::node/@id=@id">
<xsl:attribute name="class">selected</xsl:attribute>
</xsl:if>
   <xsl:value-of select="@nodeName"/>
</a>

Similar Posts

  1. Remember the Enctype for Forms!
  2. Everything Basecamp To-Do List Templates
  3. Validating a dropdpwn list in ASP.NET 2.0

Comments are closed

Options:

Size

Colors