Subject: [xsl] 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 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Having Tags when the outp, Swati Attarde | Thread | Re: [xsl] How to test by nodename i, David Carlisle |
[xsl] Having Tags when the output m, Swati Attarde | Date | Re: [xsl] Expression Logic Problem, Jeni Tennison |
Month |