[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: RE:"*NEVER* use for-each"
Mike, When a lot of people come to XSLT they see <xsl:for-each> and think "That's what I need" when it most times isn't. They should be using templates. As they start to develop their template they add <xsl:if> and <xsl:choose> all over the place within the <xsl:for-each> to get round not using templates in the first place. So to stop people making a bealine for <xsl:for-each> I always say "Beginners rule #1 *NEVER* use for-each". Daniel's solution to his own problem is ><xsl:value-of >select="ANNUALSNAPSHOT[3]/CONSENSUSVALUE/ESTIMATEDATA/child::*[position()=$ I >ndex]" /> >Now I know might not be pretty, but it DOES return what I want. $Index will >range from 1 to 9 Next he will be asking how he can increment his $Index variable which he can't do because you can't increment variables without using recursion. As he hasn't got the hang of templates yet explaining to him how to do recursion is not going to be easy. To quote Francis in another thread >People on this list find themselves bailing out people who've sailed on >to the same old rocks, and try to let others know that they're sailing >in that direction, that why we make suggestions of this kind. Ciao Chris XML/XSL Portal http://www.bayes.co.uk/xml >As a beginner, who has just used for-each to solve a problem, why should I >never use it? > >(OK, I admit having checked the <xsl:sort> description in Mike Kay's book I >could probably have used another template, but why is that preferable to >using for-each?) > >mike > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|