[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Check if XML tag exists?

Subject: Re: Check if XML tag exists?
From: Oliver Becker <obecker@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 17 Aug 2000 10:53:24 +0200 (MET DST)
xsl test if tag exists
Hi David,

> Is there a way I can check if a TAG in the XML data exists or not, even
> though the possibly existing TAG will not have any value?
> 
> Background is... in this instance everything would be hidden.
> 
> <RESTRICTED_FIELD_LIST>
> 
>   <HIDE_OFFICE_ALL />
>   <HIDE_HOME_ALL />
> 
> </RESTRICTED_FIELD_LIST>
> 
> But in this instance ALL the Office info would be hidden while only  the
> Home Address info would be hidden.
> 
> <RESTRICTED_FIELD_LIST>
> 
>   <HIDE_OFFICE_ALL />
>   <HIDE_HOME_ADDRESS />
> 
> </RESTRICTED_FIELD_LIST>
> 
> The HIDE_HOME_ALL is no longer in the data.
> 
> Can I check to see if a TAG exists or not?

You want to check if an *element* exists or not. :-)
Well, probably the following template does what you want:

<xsl:template match="RESTRICTED_FIELD_LIST">
   <xsl:if test="HIDE_HOME_ALL">
      <!-- Ah, HIDE_HOME_ALL is present -->
      <!-- Do something reasonable ... -->
   </xsl:if>
</xsl:template>

Note: if you want to test wether an element is empty or not, you
have to compare with '' or apply the string function:
   <xsl:if test="string(HIDE_HOME_ALL)">
      <!-- HIDE_HOME_ALL is present and not empty -->
   </xsl:if>
   
Hope that helps,
Oliver


/-------------------------------------------------------------------\
|  ob|do        Dipl.Inf. Oliver Becker                             |
|  --+--        E-Mail: obecker@xxxxxxxxxxxxxxxxxxxxxxx             |
|  op|qo        WWW:    http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.