Re: [xsl] Start and end an anchor tag in 2 different if's?

Subject: Re: [xsl] Start and end an anchor tag in 2 different if's?
From: JBryant@xxxxxxxxx
Date: Tue, 5 Oct 2004 11:13:10 -0500
That never works. XML enforces strict nesting, so both the closing and 
ending tags for a child element have to be within the parent element. 
Remember that an XSL stylesheet is also an XML document.

I agree that it would sometimes be handy, but then it wouldn't be XML.

Instead, you need something like this:

<xsl:if test="district_active='1'">
  <xsl:choose>
    <xsl:when test="substring(full_name,1,6) = 'Vacant'">
      <a>
        <xsl:attribute name="href">stuff</xsl:attribute>
        <xsl:value-of select="'Vacant'" />
      </a>
    </xsl:when>
    <xsl:otherwise>
      <a>
        <xsl:attribute name="href">stuff</xsl:attribute>
        <xsl:value-of select="full_name" />
      </a>
    </xsl:otherwise>
  </xsl:choose>
</xsl:if>

Disclaimer: I rearranged that pretty quickly, so it may be off a bit, but 
I trust it gives the idea. Also, I truncated the attribute content just to 
make this snippet more readable.

Happy coding.

Jay Bryant
Bryant Communication Services

Current Thread