xsl-list
[Top] [All Lists]

Re: possible nested loops

2006-02-14 15:38:42
garry(_at_)skegnessgrammar(_dot_)org 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.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>