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

Re: problem with handling conditional for loops

Subject: Re: problem with handling conditional for loops
From: "Aron Bock" <aronbock@xxxxxxxxxxx>
Date: Wed, 27 Apr 2005 15:32:36 +0000
xsl conditional loops
Rahil, the reason prior respondents note that you likely don't need nested loops is because we're using an imperative algorithm with a language that has a declarative paradigm. It's similar to using a cursor-based approach in SQL, as opposed to a SET-based one. Imperative approaches and cursors have their uses in either area, of course, but in this case we may have what XP-ers call 'smelly code'.

That said, the way I've seen these things done in XSL is to apply enough predicates to the node selection expression (in our 'outer loop', as it were), so that only applicable candidates are passed in. This obviates the need for an innder loop.

If the two 'loops' look in different paths, simply union them in the select expression, if possible. Something like:

<xsl:for-each select="/foo/bar/Value/@name | /foo/bar/@name">

Looks like you could also use keys, defined to search different paths, to reduce clutter.

If you would post your input and output files I'm sure people here could suggest an XSL-esque way of doing things.



From: Rahil <qamar_rahil@xxxxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: problem with handling conditional for loops Date: Wed, 27 Apr 2005 15:36:11 +0100

Jon Gorman wrote:

..... If it's the latter, I hope it doesn't occur to
frequently. Do remember this is a pretty large list spanning across
quite a few time zones. I was sleeping soundly when your first email
was sent to the list this morning. Of course, I realize sometimes
postings do get ignored.

You're right. I did feel that my mail had got lost in the many other mails that were posted around the same time.

However since my work has come to a halt because of this problem I decided to repost with a simplified statement. Ive simplified my code for clearer understanding of my problem

<xsl:for-each select="document(First.xml)/SubConcepts/SubConcept">
<xsl:variable name="clsName" select="@name"/>
<xsl:for-each select="document(Second.xml)/SubConcepts/SubConcept[1]/Value">
<xsl:when test="contains(normalize-space(lower-case($ontSecondVal)),normalize-space(lower-case($clsName)))">
<xsl:call-template name="firstLevel">

IN CASE I dont find $clsName in any of the Value/text() of SubConcept[1], I'd like to loop though the remaining SubConcept nodes to check whether $clsName exists in its @name.

I hope this is slightly clearer. Else please let me know.


Dont just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/

Current Thread


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.
First Name
Last Name
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.