XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Billy DeanSubject: Need help converting CSV to Nested XML
Author: Billy Dean
Date: 13 Oct 2007 10:27 AM
Originally Posted: 13 Oct 2007 10:19 AM
I have been able to use the CSV to XML to convert to XML, but can't create the nested XML as I need to. Here's my problem:

Input file:

Network:, Name0, ... 5 fields
Network:, Name1, ... 5 fields
Network:, Name2, ... 5 fields
Host:, HostName1, ... 10 fields
Host:, HostName2, ... 10 fields
Host:, HostName3, ... 10 fields
Network:, Name3, ... 5 fields
Host:, HostName4, ... 10 fields

I can use the CSV to XML and get the following:

<Network range= name='Name0' ... 5 attributes/>
<Network range= name='Name1' ... 5 attributes/>
<Network range= name='Name2' ... 5 attributes/>
<Network range= name='Name3' ... 5 attributes/>
<Host address= name=Hostname1 ... 10 attributes/>
<Host address= .../>
<Host address= .../>
<Host address= .../>

But this is not what I want. I want the Hosts to be nested under the Network like this:

<Network ... />
<Network ... />
<Network ... >
<Host address= .../>
<Host address= .../>
<Host address= .../>
<Network ... >
<Host address= .../>

This stems from the perceived limitation in the CSVtoXML tool that doesn't allow me to create 'Child-elements' during the initial conversion.

Is there something I'm missing? Or is there an easy XSLT transform to deal with this?



Tony LavinioSubject: Need help converting CSV to Nested XML
Author: Tony Lavinio
Date: 15 Oct 2007 12:04 AM
This is a standard XSLT grouping problem.
See http://www.jenitennison.com/xslt/grouping/index.xml for

This can be handled by putting the converter URL as the
input to XSLT, or by using the Pipeline to link together
the conversion and the grouping steps.

Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.