This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Newbie: See if a node exists!
- From: Joerg Heinicke <joerg dot heinicke at gmx dot de>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Fri, 07 Jun 2002 15:36:05 +0200
- Subject: Re: [xsl] Newbie: See if a node exists!
- References: <3AC40EBEC657D311BA8800A0C9E9338FDA2B84@fwp-gw.fwpmatthews.co.uk>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Anand Kuppa wrote:
Try using COUNT
you could do something like
<xsl:when test = "if COUNT(BLOCK) > 0>
........what u want to do
</xsl:when>
lemme know if it worked...
cheers
Hello Anand,
you never need to count elements, if you only want to know, whether an
element exists or not.
<xsl:if test="BLOCK">
</xsl:if>
is enough.
Even if you want to know whether there are 4 elements or not, you don't need
to count them:
<xsl:if test="BLOCK[4]">
</xsl:if>
tests whether a 4th BLOCK-element does exist.
Your test as above has two little errors:
<xsl:when test="count(BLOCK) > 0">
</xsl:when>
There must not be an 'if' in the test. The element already has the name
<xsl:if/> or <xsl:when/>. And - as David wrote - XML is case sensitive, so
their is no XPATH function COUNT(), but count().
Regards,
Joerg
--
System Development
VIRBUS AG
Fon +49(0)341-979-7419
Fax +49(0)341-979-7409
joerg.heinicke@virbus.de
www.virbus.de
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list