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

Re: [xsl] check for optional element

Subject: Re: [xsl] check for optional element
From: Jarkko.Moilanen@xxxxxx
Date: Thu, 22 Jan 2004 12:10:33 +0200

Lainaus Nikolas Nehmer <Nikolas.Nehmer@xxxxxxxxxxx>:

< Hi,
< I want to check if an optional element is present in my XML document and
< if so I want to react to this fact. For example I have an optional
< element subsidiary in my Organesation.xml. If a subsidiary is present I
< want to create an additional column in my HTML table. How could I
< realise this test. The element-available() function does only apply to
< instruction elements I think?!
< Best regards,
< Nick

Source tree:

<?xml version="1.0"?>
 <subsidiary>is here</subsidiary>

 only foobar


<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"

<xsl:template match="/">
  <xsl:for-each select="root/elements/foobar">
   <xsl:if test="subsidiary">
     <xsl:copy-of select="."/>



<?xml version="1.0" encoding="utf-8"?>
 <subsidiary>is here</subsidiary>

* Jarkko Moilanen                                 *
* Dokumentoinnin kehittäjä                        *
* Profound XML technology Expert                  *
* DokuMentori Oy                                  *
* www.dokumentori.fi                              *

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

Current Thread