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

Re: Skip Nodes If Condition

Subject: Re: Skip Nodes If Condition
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Tue, 25 Jun 2002 23:34:46 +0200
xsl if condition
Hello Scott,

what you did in your template, is more or less useless. You do not output label, if it's empty. So you don't need the if-test, because outputting an empty label has the same effect.

You must do it earlier: <xsl:apply-templates select="ad/ad_content[normalize-space(label)]"/>

or you add the if-test around the content of the template:

<xsl:template match="ad_content">
  <xsl:if test="normalize-space(label)">
    <h3>ad_content</h3>
    <xsl:value-of select="label" />
  </xsl:if>
</xsl:template>

A third possibility is to add a third empty template:

<xsl:template match="ad_content[not(normalize-space(label))]"/>

Regards,

Joerg

Scott Purcell wrote:
> Hello,
> I am trying to skip certain nodes if a condition is met.
> I have searched the mailing list, but cannot find a good match for my problem.
> If the ad_content does NOT contain a label, I want to skip it. Is it best to do a "if test" like I did below, or is there a better technique that I need to learn?
>
> Thanks
> Scott
>
> Here is a piece of the xml:
> <ad_content>
> <item_type>hidden</item_type>
> </ad_content>
> <ad_content>
> <label>headline</label>
> <item_type>hidden</item_type>
> </ad_content>
>
> I am sending this to a template match. eg:
> <xsl:apply-templates select="ad/ad_content" />
>
>
> <!-- template -->
> <xsl:template match="ad_content">
> <h3>ad_content</h3>
> <xsl:if test="label[.!='']"> <!-- make sure it is not blank -->
> <xsl:value-of select="label" />
> </xsl:if>




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-2013 All Rights Reserved.