[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] determining if one or more instances of a child are present in the current node element


Subject: RE: [xsl] determining if one or more instances of a child are present in the current node element
From: Jarno.Elovirta@xxxxxxxxx
Date: Thu, 18 Sep 2003 12:38:23 +0300

Hi,

> Because my current node will be <Paragraph> and not <paraitem>.

The child axis is used on abbreviated steps -- you should know, having read the spec, right -- so

  <xsl:if test="ParaItem"/>

if the same as

  <xsl:if test="child::ParaItem"/>
 
> Also, it can have other elements as children. So I need to have a
> specific "test" that checks if that child exists before APPLYING
> stylesheets for that child.
> 
> <Paragraph>
> 	<ParaItem>
> 	<ParaItem>
> 	<ParaItem>
> ....
> <Paragraph>
> 
> Let me know :). Is there a better expression to check if the current
> NODE (paragraph) contains ATLEAST one child PARAITEM.

Makes no difference if there are other child elements, because

  <xsl:if test="ParaItem"/>

selects all the "ParaItem" child elements of the current node, casts the node-set to a boolean, and that will be true if the node-set contains more than zero nodes.
 
Cheers,

Jarno

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



Current Thread