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 6th, 2006, 12:22 PM
Registered User
Join Date: Feb 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Producing a loop of XML in CSV


First post here, so firstly I would like to say thank you in advance for anyone who reads and helps me out.

I would like to take some XML and generate CSV via XSLT. I'm not too bad at that however I have an issue with how i need it to look.

My XML links together by using ids to have parents etc (clearly if you look at the XML below). Basically I need to produce the result below it and I am really struggling, due to the fact theat I am confused with loops and things like that within XSLT.

The parentid relates to a group id.

To let you know the employee numbers will always be in the bottom tier but there can be unlimited tiers and groups.

Hope that makes sense. Any help greatly appreciated.

<company comp-id="12345">
    <tier depth="1" name="Company">
        <group name="My Company" groupid="1" parentid="0" />
    <tier depth="2" name="Division">
        <group name="Shop" groupid="3" parentid="1" />
        <group name="Office" groupid="4" parentid="1" />
        <group name="Warehouse" groupid="5" parentid="1" />
    <tier depth="3" name="Department">
        <group name="Admin" groupid="6" parentid="3">
            <employee number="166" name="Dave" />
            <employee number="345" name="Phil" />
        <group name="Assistants" groupid="7" parentid="4">
            <employee number="678" name="James" />
            <employeenumber="034" name="Bill" />
        <group name="Managers" groupid="8" parentid="5">
            <employee number="87" name="Paul" />
12345,My Company
12345,My Company,Shop
12345,My Company,Shop,Admin
12345,My Company,Shop,Admin,166
12345,My Company,Shop,Admin,345
12345,My Company,Office
12345,My Company,Office,Assistants
12345,My Company,Office,Assistants,678
12345,My Company,Office,Assistants,034
12345,My Company,Warehouse
12345,My Company,Warehouse,Managers
12345,My Company,Warehouse,Managers,87

Similar Threads
Thread Thread Starter Forum Replies Last Post
XML To CSV with XSLT and Java pcroadkill XSLT 3 February 8th, 2012 11:55 AM
.csv to xml conversion balakrishna XML 0 March 5th, 2007 01:07 PM
CSV and XML with PHP NEO1976 PHP How-To 1 July 17th, 2006 02:33 AM
XML to CSV reloader2 XML 2 September 7th, 2005 08:51 AM
convert xml to csv woofy77 XSLT 0 December 8th, 2003 02:05 AM

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