[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: checking if child exists


Subject: Re: checking if child exists
From: Mike Brown <mike@xxxxxxxx>
Date: Sat, 24 Jun 2000 10:17:22 -0600 (MDT)

> I wanted to know if there's a way with xslt (i'm sure there is) to check if
> a child of a node exists.

Yes, just write an XPath expression that would identify the node-set
that would be the children you're looking for. If it's empty, it will test
false. If there are nodes in the set, it will test true.

<xsl:if test="*">
  There exists an element child of current node, in the null namespace.
</xsl:if>

<xsl:if test="foo">
  There exists a 'foo' element child of current node, in the null namespace.
</xsl:if>

   - Mike
____________________________________________________________________
Mike J. Brown, software engineer at         My XML/XSL resources:
webb.net in Denver, Colorado, USA           http://www.skew.org/xml/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords