|
[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
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






