Subject: Re: [xsl] check if a node is empty From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 17 Oct 2002 15:38:30 +0100 |
Hi jeremyf, > I have an XML document that may contain nodes with no children > > <node> > </node> That's an element called 'node' with a single text node child (the text node is just whitespace, but it still counts as a text node unless you're stripping spaces?). > I need to test if this is the case in my XSL in order to output the > correct information I suspect that you want to test whether the 'node' element contains any element children, in which case the test should be: <xsl:template match="node"> <xsl:choose> <xsl:when test="*"> 'node' element has child elements </xsl:when> <xsl:otherwise> 'node' element doesn't have child elements </xsl:otherwise> </xsl:choose> </xsl:template> But you might mean any one of: test="node()" -- any child nodes test="* or text()" -- any element or text children test="* or normalize-space()" -- any element or text aside from whitespace I hope that one of those fulfills your requirements. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] check if a node is empty, jeremyf | Thread | Re: [xsl] check if a node is empty, David Carlisle |
RE: [xsl] check if a node is empty, Macaulay,Malcolm (US | Date | Re: [xsl] check if a node is empty, David Carlisle |
Month |