Best XML structure

Questions about XML that are not covered by the other forums should go here.

Best XML structure

Postby xuitos » Wed May 02, 2012 6:47 am

I'm quite new to constructing xml, and I was hoping for some initial guidance on best practices.

I have an Excel file that needs to be converted to xml.

It's in tabulator form:
Row A has ID
Row B has Name, with entries for First, Middle, Last in three cells running down the column.
Row C has Team, with a list of teams
Row D has Played, with the number of games played for each team.
Row E has Goals, with the number of goals kicked in each team.

I have exported the file as csv, and import it into Oxygen as a text file. But then I get lost. Should I make a schema and then import?
Anyway, any help would be much appreciated!
xuitos
 
Posts: 1
Joined: Wed May 02, 2012 6:39 am

Re: Best XML structure

Postby Costin » Wed May 02, 2012 1:07 pm

Hi,

You can import an Excel file that has a simple format (either by transforming it to CSV and import as text, or by importing it as an xls file) with no need for a preceding schema file. After importing the file, you could switch to "Grid" mode which is a better approach to the way that the original file is displayed in Excel.
Otherwise, in case you need to customize the format of the imported file, then you should consider creating a custom XSL file.

There are several ways to do this import.

1. You can use either Oxygen XML Editor or Developer to import from Text/Excel to XML(File -> Import -> Text file/MS Excel file...).
Note however that this function has some limitations:
- it can only import the old Excel 97/2000/XP/2003 format.(.xsl)
- it can only import one sheet at a time.
- the table from the sheet is assumed to start from the top left corner(you cannot define the starting and ending row/column of the data to import). If there are other labels, titles or other data before the actual table, the import will get you mixed results.


2. If you have Excel documents in the new format(.xslx), Excel 2007/2010, you could first convert it to the older ".xsl" format - compatibility mode before importing it in oXygen. However, Oxygen also provides a small example XML stylesheet for extracting data directly from the .xslx file. The sample is located in:
Oxygen/samples/ooxml/extractFromExcel.xsl
This stylesheet will have to be modified to your needs, so some XSLT knowledge is required. The advantage is that after developing this stylesheet you can use it to import automatically in the desired XML format.

There are some video demonstration on our web site about how this could be used:
http://www.oxygenxml.com/videos.html#vt ... ocuments_t
Note that the videos are showing extraction from Word and exporting to Excel, but the procedure is the same for extraction/import from Excel.

3. There is an additional method of getting data in Oxygen from Excel. It can be copied directly from Excel to the clipboard and pasted in Oxygen in the Grid mode. Some preparation is required for this.
You have to create in Oxygen an XML file that replicates the structure of the table(same number of columns), switch to Grid mode and paste the copied content from Excel at top left corner from the blank table.

e.g.
Code: Select all
<root>
<row>
  <item1/>
  <item2/>
  ...
  <itemN/>
</row>
<row>
  <item1/>
  <item2/>
  ...
  <itemN/>
</row>
</root>


You can already name the cell/item elements in any way you want. But the row elements must have the same name(e.g. "row" in this case).

Regards,
Costin
Costin Sandoi
oXygen XML Editor and Author Support
Costin
 
Posts: 86
Joined: Mon Dec 05, 2011 6:04 pm


Return to General XML Questions

Who is online

Users browsing this forum: No registered users and 1 guest