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

Re: selecting a element without it's child element

Subject: Re: selecting a element without it's child element
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Wed, 10 Nov 2010 12:05:04 +0000
Re:  selecting a element without it's child element
On 10/11/2010 11:03, srinivasan.p@xxxxxxxxxx wrote:
Thanks Pankaj, its working fine now.



<xsl:variable name="filename"><xsl:value-of
select="book/title/text()[1]"/></xsl:variable>

--Pankaj


That's not a good solution, however. It's dependent on properties of your input that might not always hold, and that weren't specified in your description of the problem - notably, that all the text of the title other than the indexterm is in a single text node that is an immediate child of the title element. Pankaj has seen one example of your input data, and leapt to the conclusion that all other examples will be the same. You've run it on a single test case (I imagine), and concluded that it's correct because it works on that test case.


Learn to use template rules: they are the right way to tackle this kind of problem. In fact, they are the right way to tackle nearly every XSLT problem.

Michael Kay
Saxonica

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.