Convert CSV to XML using an existing XSD

This should cover W3C XML Schema, Relax NG and DTD related problems.
afuente
Posts: 1
Joined: Tue Jun 21, 2011 3:17 pm

Convert CSV to XML using an existing XSD

Post by afuente » Tue Jun 21, 2011 3:22 pm

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.

adrian
Posts: 2740
Joined: Tue May 17, 2005 4:01 pm

Re: Convert CSV to XML using an existing XSD

Post by adrian » Tue Jun 21, 2011 5:28 pm

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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

vcocco
Posts: 4
Joined: Thu Aug 29, 2019 10:46 pm

Using the Import Utility to create XML file

Post by vcocco » Fri Feb 12, 2021 9:43 pm

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
Attachments
oxygenImportPreview.png
oxygenImportPreview.png (164.79 KiB) Viewed 1246 times

adrian
Posts: 2740
Joined: Tue May 17, 2005 4:01 pm

Re: Convert CSV to XML using an existing XSD

Post by adrian » Mon Feb 15, 2021 12:15 pm

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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

vcocco
Posts: 4
Joined: Thu Aug 29, 2019 10:46 pm

Re: Convert CSV to XML using an existing XSD

Post by vcocco » Mon Feb 15, 2021 8:30 pm

Thanks Adrian.
That did it.
image.png
image.png (34.08 KiB) Viewed 1201 times

Post Reply