XML Structure Overview

When you connect to a sample XML file by using the Database Setup wizard, the wizard scans for an XML schema, which can be referenced in the XML file itself. If the schema is not in the XML file, you are prompted to provide a schema file, if one exists. Then, you are prompted to select a master element and the parent and child elements that you want to include. After you successfully complete the wizard, the data is converted into a table that uses a consistent field name syntax. You can then use your database fields as data sources for your document.

ClosedSchema File

The schema file is an XML Schema Definition (XSD) or document type definition (DTD) file that provides information about the XML file, such as which elements or attributes are optional and therefore might not appear in this particular XML file but might appear in other XML files of the same schema. The schema file also indicates whether a particular element appears only one time or might appear multiple times.

If you do not provide schema information, either within the XML sample file itself or in a separate XSD or DTD file, the wizard infers the schema from the sample XML file. This inference includes the assumption that elements might be repeated even if the sample XML file contains only one instance of the element. Additionally, when no schema information is present, the data type for all elements defaults to "text." (You can change the data type in the Database Setup dialog.)

The XML schema is not required, but without it, you cannot use any optional fields that are not present in your sample XML.

ClosedMaster Element

In BarTender, the master element is the XML element that defines a database record. Typically, only one element is selected as the master element, but you can use the advanced settings to specify that more than one occurrence of an element is selected from different locations in the schema, as long as their types (local name and/or namespace) are the same.

The Database Setup wizard automatically determines the default master element, based on which element in the schema has the highest number of occurrences in the XML file. However, you can change this selection in the wizard as needed. Only element nodes, not attributes, can be master elements.

Each instance of the master element results in one row in the database table. The field values (columns) are retrieved from the master element and its parent and child elements according to your settings.

For example, suppose that you are using the following XML file.

When <owl> is selected as the master element, the following database results. Because there are two instances of this element in the sample XML file, there are two records in the database, as follows.


ClosedParent and Child Elements

The parent and child elements of the master element and their attributes can contribute field data to each database record.

For example, suppose that you are using the following XML file.

In this XML file, the child elements of the master element <owl> are <species>, <name>, and <region>. The following database results.


You can select the parent and child elements that you want to use in the Database Setup wizard and then configure them in the Database Setup dialog.

ClosedAttributes

An element's attributes define the properties of the element. For example, if your XML file contains an <Employee> element, the attributes of that element might include "ID", "LastName", "Department", and so on, depending on the information that you need to include in your database.

For example, suppose that you are using the following XML file.

In this XML file, the attribute of the <owl> element is <id>. The following database results.


You can select the attributes that you want to use for each element in the Database Setup wizard and then configure them in the Database Setup dialog.

Related Topics