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

Re: possible nested loops

Subject: Re: possible nested loops
From: Kamal Bhatt <kbhatt@xxxxxxxxx>
Date: Wed, 15 Feb 2006 09:38:42 +1100
w3cschool
garry@xxxxxxxxxxxxxxxxxxx wrote:

I wonder if someone could point me in the right direction to solve my
problem. I need to transform an xml file to html. I have tried to make a
stylesheet but none of my efforts have been successful.
The xml has around 800 pupil records (<pupil>) so I want to iterate over
each pupil node. Within each pupil node there are other nodes which
repeat, so for each pupil I need to iterate over child nodes of which
there may be none or many of each type. I suspect a nested loop of some
sort may help but I have not been able to implement one, any ideas?
regards
garry


It would help if we had a copy of your stylesheet (at least of what you have done) and some more information on the xml. ie an example snippet. By the language you are using, I suspect you have a fundamental lack of understanding of how XSLT works. There is no real concept of "iteration" in XSLT. Instead, what you do is use a template to find a match and do some action to this matching node. This action may include selecting values, storing values in a variable for later use, processing then selecting values or processing each child node or calling another template to process each child node. There are probably other operations that I have not included, but for simple conversion to HTML, this is probably only things you need to worry about. Have another look at some tutorials (the w3cschool tutorials are good for beginners). Pay close attention to <xsl:attribute>, <xsl:for-each> and <xsl:apply-templates>, I suspect that this is all you require to do what you need (assuming your data is well strucutred).

Cheers.

Kamal.

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.