Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checking for a missing node 1

Status
Not open for further replies.

jrenae

Programmer
Jan 18, 2006
142
US
Hello,

I'm trying to check for a missing node and display something.

If the node exists I show the child nodes, but how do I display something if it doesn't exist at all? The following works fine for showing what is there. But if Positions is missing I want to print out something like 'all'.

Code:
      <xsl:if test="Positions/Position != ''">
        <span style="font-weight:bold">
          <xsl:for-each select="Positions/Position">
          <xsl:value-of select="."/>
            <xsl:if test="position() != last()">, </xsl:if>
          </xsl:for-each>
        </span>
      </xsl:if>


Thanks for any help.

 
something along this line preserving the part you are satisfied.
[tt]
[blue]<xsl:choose>
<xsl:when test="count(Positions)=0">
<span style="font-weight:bold"><xsl:text>all</xsl:text></span>
</xsl:when>
<xsl:eek:therwise>[/blue]
<xsl:if test="Positions/Position != ''">
<span style="font-weight:bold">
<xsl:for-each select="Positions/Position">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each>
</span>
</xsl:if>
[blue]</xsl:eek:therwise>
</xsl:choose>[/blue][/tt]
 
Thank you tsuji! This worked perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top