From The Document Foundation Wiki
Jump to: navigation, search


XML Source feature allows user to import data from arbitrarily structured XML content into cells in an existing spreadsheet document. It allows XML content to be imported either partially or in full, depending on the structure of the XML content and the map definitions that the user defines. The user can specify multiple non-overlapping sub-structures to be mapped to different cell positions within the same document. The user can import either element contents, attribute values or both.

NOTE: The initial revision of this feature as planned in 4.0 will only allow you to import XML data as a one-time event; it will not store the information about the data source once the data is imported. The future revisions will incorporate more enhancements to support more complex use cases with more complex user interface.

Access from Menu

Selecting Data ▸ XML Source launches the XML Source dialog.

XML Source access from menu

XML Source Dialog

XML Source dialog

The dialog consists of four parts.

Source file

This lets you specify the path to the XML file that you wish to import into your document.

Structure tree

This pane shows the structure of the source XML content as a tree. This is initially empty, and gets populated when you specify the source file.

Each element in the tree can be one of three types:

  • attribute,
  • single non-recurring element, and
  • recurring element.

A non-recurring element is an element that can only occur once under the same parent. It is mapped to a single cell in the document.

A recurring element is an element that can appear multiple times under the same parent. It serves as an enclosing parent of a single record entry of multiple record entries. These entries are imported into a range those height equals the number of entries plus one additional header row.

Mapped cell position

This field specifies the position of a cell in the document that an element or an attribute is linked to. If it's a non-recurring element or an attribute, it simply points to the cell where the value of the linked element/attribute will get imported. If it's a recurring element, it points to the top-left cell of the range where the whole record entries plus header will get imported.

Import / Cancel buttons

Pressing the Import button starts the import process based on the link definitions that the user has provided. Once the import finishes, the dialog will close. Pressing the Cancel simply closes the dialog without importing data.

Missing bits

  • Add visual indication on mapped elements / attributes so that the user can easily see which nodes have already been mapped.
  • Add expand / collapse buttons at each parent element in the tree.
  • ...

Feature requests

Preview content at node

Provide a content preview at each node location within the tree structure of the dialog. (from Regina)

Display explanation on non-selectable element/attribute

Not all elements or attributes can be mapped to document. If an element or an attribute cannot be mapped, selecting it in the tree will leave the mapped cell reference box grayed. It would be nice to display the reason in the dialog. (from Markus).

Not show default namespace markers.

When the XML content is namespaced, it displays ns0: ns1: etc to refer to namespaces. It would be nice to not show those indicators for default namespaces. (from Markus). There are technical difficulties on achieving this, however. Since default namespaces are simply a syntactical convenience in the XML standard, the information on whether a namespace is default or not is lost by the time the parser passes the information on to the handler. (Kohei)