Creating Your Own XML Map
With your newly created XSD in hand, you can create your XML-based data entry template. Start by opening a new Excel workbook and activating the XML Source task pane by selecting XML Source in the Developer tab. Next, click the XML Maps button to activate the XML Maps dialog box, shown here in Figure 12-6.
|
XML Maps |
(UES | |||
|
XML maps in bhis workbook: | ||||
|
Name Roob Namespace | ||||
|
< mi |
1 l> | |||
|
Rename,,, [ Add.,, ] Delete |
li <* . |
Cancel | ||
Here, you will click the Add button to link to the MySchema.xsd you created in the C:\ drive. Once your XSD is referenced, click OK to create the map. When your XML map is created, the XML Source will show you the elements that are available for use in your spreadsheet.
Keep in mind that you are not limited to one XML mapping. You can map multiple XML documents and schemas. Simply activate the XML Maps dialog box and add another link to an XML document or schema.
At this point, you can drag the Employee parent element to your spreadsheet to create a data entry table. From here, you can add a little formatting to achieve a particular look and feel. Now here comes the impressive bit. Enter some data into the template, as demonstrated here in Figure 12-7.
Enter Employee Enter Employee Enter Employee Enter Invoice Enter Invoice ID First Name Last Name Number Amount
Figure 12-7
Now you need to export the data entered into your template as an XML document by right-clicking anywhere inside the mapped range and selecting XML O Export. This will open a dialog box where you will be asked to specify a name and location for the XML export. Once the document is exported, you can open it to see that your data has indeed been output into the XML structure specified by your custom schema. Figure 12-8 demonstrates the output for the data entered in Figure 12-7.
<?xml version="l,0" encoding="UTF-8" standaione="yes" ?>
<EmployeeSales xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Empid>24601</Empid> <FirstName>Mike</FirstName> â– iLastName>Alexander</LastName> <InvoiceNumber>100</InvoiceNumber> <InvoiceAmount>2400</In voice Amount > </Employee>
<Empid>211321</Empid> <FirstName>John</FirstName> <LastName>Green</LastNarne> <InvoiceNumber>200</InvoiceNumber> <InvoiceAmount>5400</In voice Amount > </Employee>
<Empid>203400</Empid> <FirstName>Rob</FirstName> <LastName>Bouey</LastName> <InvoiceNumber>300</InvoiceNumber> <InvoiceAmount>3300</In voice Amount > </Empioyee> </EmployeeSales>
You can imagine how automating the export functionality would allow a user to send entered data to a specified location with the click of a button. Once the data is in an XML document, any procedure or application that can process the XML document will be able to consume the data.
As mentioned at the beginning of this section, the scenario you just walked through is just one of countless ways you can choose to implement your own XML maps. You are encouraged to take some time to think about your data processes in terms of XML.
Post a comment