Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 3rd, 2011, 03:47 PM
Registered User
 
Join Date: Feb 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Nested Loop to get Sub Item from XML by XSLT

Hi Friends, I am very new to XSLT and right now am learning XSLT, XPATH and Xquery. I stuck at one problem when i was learning. I want to run nested loop on below sample xml file which is
<categoryArrya>
<category>
<ID>1</ID>
<Name>Books</Name>
<ParentID>1</ParentID>
<Category>
<category>
<ID>2</ID>
<Name>Fitness</Name>
<ParentID>2</ParentID>
<Category>
<category>
<ID>3</ID>
<Name>Harry Potter</Name>
<ParentID>1</ParentID>
<Category>
<category>
<ID>4</ID>
<Name>Abcd Book</Name>
<ParentID>1</ParentID>
<Category>
<category>
<ID>5</ID>
<Name>Home Zym</Name>
<ParentID>2</ParentID>
<Category>

I want to run a nested loop of for each where i can have table of
category which contain another table of subcategory based on id and parent id but not able to do this... Please help me i am doing my msc project...
 
Old February 4th, 2011, 06:06 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If your attempt to solve the problem didn't succeed, it's best to show us your attempt, so that we can see where your misunderstanding of the spec lies. Don't be frightened to show your work to others, it's the best way of getting feedback and learning from it.

However, "nested loops" is the wrong paradigm when you're designing XSLT code. Learn to use template rules: start by writing a template rule for each kind of element, that does something with that element and then calls xsl:apply-templates to process the child elements, thus recursing down the XML tree structure.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested Loop Numbering Vips XSLT 1 December 27th, 2010 06:24 AM
Nested For-Each Loop In XSLT dghosh XSLT 10 July 2nd, 2008 04:34 AM
nested loop adnan2 Java Basics 1 July 13th, 2007 04:21 PM
Nested Do Until Loop goels Access VBA 2 September 30th, 2004 08:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.