Map and unmap XML elements Excel 2007
Author: mety Labels:: Map and unmap XML elements Excel 2007
To import and export XML data files, you must create an XML map, and then map and unmap XML elements to cells to get the results that you want.
Locate XML Schema and XML data filesThere are several ways to obtain XML Schema and XML data files. Get the files from another database or applicationOften, you have access to XML Schema (.xsd) (XML Schema: A formal specification, written in XML, that defines the structure of an XML document, including element names and rich data types, which elements can appear in combination, and which attributes are available for each element.) and XML data (.xml) files that were created in another database or application. For example, a line-of-business application may export data into XML file format, a commercial Web site or Web service may supply an XML file, or a customized application developed by your IT department may create an XML file as one of its functions. Convert a text fileIf you have a text file that you want to use, you can convert the text file to an XML file and then map it in Microsoft Office Excel 2007. For example, you can use Microsoft Office Access and Microsoft Office Excel to convert a text file to an XML file:
If you don't have convenient access to XML files, the following sample XML files contain basic XML elements and structures that you can use to test XML maps
Create an XML mapYou create an XML map by adding an XML Schema to a workbook. The schema can be copied from an XML Schema file (.xsd), or Excel can attempt to infer one from an XML data file (.xsd).
There are several types of XML Schema constructs that Excel does not support. The following list details the XML Schema constructs that cannot be imported into Excel: <any> This element allows you to include elements that are not declared by the schema. <anyAttribute> This element allows you to include attributes that are not declared by the schema. Recursive structures A common example of a recursive structure is a hierarchy of employees and managers in which the same XML elements are nested several levels. Excel does not support recursive structures that are more than one level deep. Abstract elements These elements are meant to be declared in the schema, but never used as elements. Abstract elements depend on other elements being substituted for the abstract element. Substitution groups These groups allow an element to be swapped wherever another element is referenced. An element indicates that it is a member of another element's substitution group through the <substitutionGroup> attribute. Mixed content This content is declared by using mixed="true" on a complex type definition. Excel does not support the simple content of the complex type but does support the child tags and attributes that are defined in that complex type.
Map XML elementsYou map XML elements to single-mapped cells and repeating cells in XML tables so that you can create a relationship between the cell and the XML data element in the XML Schema.
Issue: All of the XML commands are dimmed, and I cannot map XML elements to any cells. Check to see if the workbook is shared. (On the Review tab, in the Changes group, click Share Workbook.) After you create a shared workbook, you can no longer map XML elements to any cells. If you want to map XML elements in a workbook that you want to share, you must map the XML elements to the cells that you want, import the XML data, remove all of the XML maps, and then create a shared workbook. Issue: I cannot copy an XML table to another workbook. An XML table (which contains data) has an associated XML map (which defines the data structure). This XML map is stored in the workbook. However, when you copy an XML table to a new workbook, the XML map is not automatically included. So, instead of creating an XML table, an Excel table is created that contains the same data. If you want the new table to be created as an XML table, do the following:
Issue: When I map a repeating element to a merged cell, Excel unmerges the cell. Although you can map nonrepeating elements to a merged cell, you cannot map a repeating element to a merged cell. If you attempt to map a repeating element — or an element that contains a repeating element — to a merged cell, the cell is unmerged and the element is mapped to the cell where the pointer is located. This is the expected behavior, because repeating elements are designed to work only with unmerged cells. Unmap XML elementsYou unmap XML elements from a mapped cell or XML table because you decide not to use them, or because you don't want the contents of cells to be overwritten when you import XML data. For example, you may want to unmap an XML element if it is currently mapped to a single-mapped cell or repeating cells that contain formulas and you don't want to overwrite the formula when you import an XML file. After you import XML data, you can remap the XML element to the cells that contain the formulas, so that you can export the results of the formulas to the XML data file.
|