how to test an empty element in XSL?

Discussion in 'Java' started by Matt, Oct 12, 2004.

  1. Matt

    Matt Guest

    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!!
     
    Matt, Oct 12, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John

    empty/non-empty element

    John, Jul 15, 2003, in forum: XML
    Replies:
    1
    Views:
    1,039
    Klaus Johannes Rusch
    Jul 16, 2003
  2. Matt
    Replies:
    6
    Views:
    3,999
  3. Replies:
    1
    Views:
    3,622
    A. Bolmarcich
    May 27, 2005
  4. adrian
    Replies:
    2
    Views:
    10,255
    toudidel
    Aug 25, 2005
  5. Lukas
    Replies:
    3
    Views:
    820
    spiff
    Nov 10, 2005
Loading...

Share This Page