how to test an empty element in XSL?

M

Matt

How can XSL detect empty elements, for example, <author></author> or
<author/> ??

The XML structure can be
<book>
<author></author>
<title></title>
</book>

The XSL has the following
<UL>
<LI>book author: <xsl:value-of
select="/book/author"></xsl:value-of></LI>
<LI>book title: <xsl:value-of
select="/book/title"></xsl:value-of></LI>
</UL>

The problem is it will display book author: and book title: even
<author> and <title>
are empty elements.

I tried the following approaches, but still not work.

<xsl:if test="string-length("<xsl:value-of select="author" />") &gt;
0">

<xsl:count(<xsl:value-of select="author" />)></xsl:count>

any ideas? please advise. thanks!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top