[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

How to test by nodename if node exsits and not empty

Subject: How to test by nodename if node exsits and not empty
From: René de Vries <RdVries@xxxxxxxxxxx>
Date: Thu, 1 Aug 2002 12:08:16 +0200
xsl if test not empty
Hi,

I try to do this: pass a nodename of a childnode of the current node as a
parameter to a template and test if it exists and, if so, if it has a
contents and/or attributes.
My problem is that I can't get the the expression right to count the number
of attributes of $Node. For example count(@*) returns the number of
attributes for the current node and I've tried count($Node/@*),
count($Node[@*]), count($Node/*[@*]) and so on, but the parser complains
that the "expression must evaluate to a node-set".
If I don't count the attributes, <aNode xyz="someinfo"/> would be considered
empty, which I don't want.

WHAT DO I DO WRONG????

my template:
<xsl:template name="TestIfNodeExistsAndIsFilled">
    <xsl:param name="NodeName" select="'NoNodeName'"/>

    <xsl:variable name="Node">
        <xsl:copy-of select="./*[local-name()=$NodeName]"/>
    </xsl:variable>

    <xsl:if test="(not ($Node)) or (string-length(normalize-space($Node))=0
and count(### what expression? ###))">
        <Error>
            <Name><xsl:value-of select="$NodeName"/></Name>
            <Description>
                <xsl:value-of select="$NodeName"/>
                <xsl:choose>
                    <xsl:when test="(not ($Node))">
                        <xsl:text> not present</xsl:text>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:text> not filled</xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </Description>
        </Error>
    </xsl:if>
</xsl:template>

Greetings René
   {@   @}
        ^
      \_/

"You don't need eyes to see, you need vision!"


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.