This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Testing if a nodeset is empty


> Hello All,
>  I am trying to avoid certain kinds of empty tags in my xml 
> output. Looking
> at the following template, I would like to avoid an empty 
> <chapter> tag.
> Unfortunately this template does not work, it always shows 
> the chapter tags
> even if they are emtpy, what am I am doing wrong?
> 
> Thanks in advance,
> Nicholas Waltham
> 
> 
> <xsl:template match="transcal/file/section">
> <xsl:variable name="a"><xsl:apply-templates 
> select="p[@stylename='heading
> 1,Part']" /></xsl:variable>
> <xsl:if test="$a">
> <chapter>
> <xsl:value-of select="$a"/>
> </chapter>
> </xsl:if>
> </xsl:template>

RTF always has a root, so the test will always return true.

  test="string($a) = ''"

should do the trick, as you can't check if $a is empty like a node-set.

Jarno

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]