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

Re: where's here the error

Subject: Re: where's here the error
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Mon, 2 Jan 2012 20:06:07 +0000
Re:  where's here the error
On 2 January 2012 19:59, graham.heath <graham.heath@xxxxxxxxx> wrote:
> On 01/02/2012 11:17 AM, Matthieu Ricaud-Dussarget wrote:
>>
>> <xsl:template match="section/entry">
>> <h2><value-of select="title" /></h2>
>> </xsl:template>
>> The problem with this generic solution is that if there is no title
>> element (as this is the case for image/section/entry), you will get an empty
>> h2 element.
>> You can add a test here or just deal with the first solution.
>>
> Use a predicate:
>
> <xsl:template match="section/entry[boolean(title)]">
> <h2><value-of select="title" /></h2>
> </xsl:template>

Or just match on the title:

<xsl:template match="title">
    <h2><xsl:apply-templates/></h2>
</xsl:template>

plus use apply-templates instead of value-of, unless you genuinely
want only the string value.

-- 
Andrew Welch
http://andrewjwelch.com

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.