Page 1 of 1

Convert CSV to XML using an existing XSD

Posted: Tue Jun 21, 2011 3:22 pm
by afuente
I am new to oxygen, any help would be appreciated. I have an XSD and a CSV to match. I need to convert the CSV to XML and follow the XSD mappings. Can anyone help get me started or point me to an existing post that would cover this? Thanks.

Re: Convert CSV to XML using an existing XSD

Posted: Tue Jun 21, 2011 5:28 pm
by adrian
Hello,

Unfortunately Oxygen doesn't provide any automatic means to map the data from a CSV file to an XML document that conforms to an XML schema.

This has to be done manually in two steps:
1. Import the CSV to an XML file
File -> Import -> Text File. Browse for the .csv file and press OK. You will obtain the Import criteria dialog that allows you to choose the field delimiter from the CSV and customize the form of the destination XML file(Change labels).

2.
a) Process the imported XML file either manually or by transforming it with an XSLT stylesheet to conform to the schema.

or

b) Generate a sample XML Instance(Tools -> Generate Sample XML Files) from the XML schema and use the Grid mode(Document -> Edit Mode -> Grid) for both files for transferring the data(copy/paste) from the imported XML to the sample XML instance that's been generated.

You can dock the editors side by side(click and drag an editor tab to the left or to the right side) to follow both files at the same time. Restore them to the default stacked layout by using Window -> Stack Editors

You can find a similar discussion here:
match data to schema

Regards,
Adrian

Using the Import Utility to create XML file

Posted: Fri Feb 12, 2021 9:43 pm
by vcocco
I have a pipe delimited text file that I'm trying to convert to xml.
Using File -> import I'm at the Import criteria window which is showing me the XML Preview:
Image

Do I have to create another XSL sheet to remove the '<Headingx> </Headingx> tags? Or, as in another [url=topic5297.html#p16651/[post/url], would I create an XQuery document to fix this?

I want the document to display like so:
<Batch_ID> ... </Batch_ID>
<Header_Journal_Source>..data here..</Header_Journal_Source>

Will the the Import utility will allow me to manually remove the 'Heading' tags and just keep the tags in between them? I don't see an option to do this, unfortunately.

Any insight would be appreciated.
Thanks,
Vin

Re: Convert CSV to XML using an existing XSD

Posted: Mon Feb 15, 2021 12:15 pm
by adrian
Hi,

You just have to check the box for "First row contains field names" and it will use the cell values from the first row as element names.

Regards,
Adrian

Re: Convert CSV to XML using an existing XSD

Posted: Mon Feb 15, 2021 8:30 pm
by vcocco
Thanks Adrian.
That did it.
image.png
image.png (34.08 KiB) Viewed 5412 times