In my last post, I didn’t go into too much details about using Excel to produce xml files, and I still won’t but I will elaborate just a little further. It appears that with Excel, your requirements on the schema have to be on the simpler side: no parent-child relationships or list of lists. (Schemas are typically xsd or xml files that are a set of instructions detailing what fields, what order, and what data types are required.) I’m not really sure I understand what a list of lists mean other than it’s a list of other kinds of lists (duh). As an example, I’m thinking that could mean you have a list called animals and within that list, you many lists such as a list of domesticated animals, a list of wild animals, a list of aquatic animals, and so on. These lists of lists are kind of similar to the parent-child relationships so I think parent-child and list of lists are the same.
I picture the parent-child relationship as similar to set of folders in your computer directory. Excel can do xml conversions when there are only two levels of folders: a set of folders in the first level and then the ones nestled within the first set. I don’t think Excel can do a series of nestled folders such as a main folder called animals, then within that folder a set of folders for domesticated, wild, zoo and aquatic and then within those folders, yet more folders. I’m under the impression that Excel can go down only one layer, namely because Excel is essentially a flat file rather than one built upon relationships.
So keep in mind the requirement of simplicity if you want to convert an Excel file into xml document.
To convert your Excel file of data into xml, you will need a starter file which is a xsd or xml document. The starter file is typically called a schema. You can create one in Notepad. The version I did was a xml file and is shown down below at the end. The first two lines will pretty much state that the file is a xml file. After that, there will be a list of elements, describing the order that they should appear. The element names are enclosed in <> or </> tags. The </> is a closing tag. (See below.) Each record is a row of data. In order to use this starter file as a schema, you will need to fill in the data between the tags for the first 2 rows of records in Excel. Each <> opening tag must have a corresponding closing </> tag somewhere in the document. See how the opening <record> at the start of each record has a closing </record> at the end of the record? Once you’ve written up your xml file in Notepad, save it as xml.
Now you are ready to convert your Excel data into xml, using the xml starter file. This all takes place in the Developer tab. For those of you who do macros, you will already have this tab showing. The rest of you will need to go into your File-Options and Customize your Ribbon. On the right hand side, you will see a layout where you can choose what you want to display on the Ribbon. Developer is one of them.
In the Developer tab, you will see a tool for Source. One you select that, a xml Source box will appear. At the bottom of that Source box, there is a button called XML Map. Click on that button and browse to find your starter file, which should have been saved as a xml document. When you select your xml starter document, Excel will tell you that it could not find the schema and thus will determine the data formats for you. Just click ok. Now you are ready to map the elements from the Source pane onto the field headers in Excel.
When you are done mapping the elements to Excel, you are ready to Export into xml using the Export command found in the ribbon. Of course, make sure you save as xml.
And that is pretty much it.
For the ACA, the government has provided some xsd (the real schemas) and xml but unfortunately, the xml is not simple and gave me problems due to the parent-child relationships. I had to simplify it using the government’s xml as a guideline. The government’s xml combines form 1094C and 1095C into one xml. I focused first on the 1095C form, namely because there are so many forms that there is no way I will be able to hand code the information. So I got rid of the 1094C section and worked on simplifying the 1095C section. The xml that I used as a guideline is called “IRS-Form1094-1095CTransmittalUpstreamMessage”. The version below is close to what I eventually used.
Now I’m working on the macro to add back the things that I had to take out.