Import Table Content as XML Document

The steps for importing the data from a relational database table are the following:
  1. Go to menu File > Import > oXygen / Database Data.

    Clicking this action will open a dialog with all the defined database connections:

    Import From Database Data Wizard

  2. Select the connection to the database that contains the data. Only connections configured on relational data sources can be used to import data.
  3. If you want to edit, delete or add a data source or connection click on the Configure Database Sources button. The Preferences/Data Sources option page will be opened.
  4. Click Connect.
  5. From the catalogs list click on a schema and choose the required table.
  6. Click the OK button.

    The Import Criteria dialog will open next, with a default query string in the SQL Query pane:

    Import from Database Criteria Dialog

    The dialog contains the following items:

    • SQL Preview - If the SQL Preview button is pressed, it shows the labels that will be used in the XML document and the first 5 lines from the database into the Import settings panel. All data items in the input will be converted by default to element content, but this can be overridden by clicking on the individual column headers. Clicking once on a column header (ex Heading0) will cause the data from this column to be used as attribute values of the row elements. Click a second time and the column's data will be ignored when generating the XML file. You can cycle through these three options by continuing to click on the column header. If the data column will be converted to element content, the header will contain the <> symbols. If the data column will be converted to attribute content, the header will contain the = symbol, and if it will be skipped, the header will contain an x.
    • Change labels - This button opens a new dialog, allowing you to edit the names of the root and row elements, change the XML name and the conversion criterion. The XML names can be edited by double-clicking on the desired item and entering the required label. The conversion criterion can also be modified by selecting from the drop-down list ELEMENT, ATTRIBUTE or SKIPPED.
    • Save in file - If checked, the new XML document will be saved at the specified path.
      Note: If only Open in editor is checked, the newly created document will be opened in the editor, but as an unsaved file.
    • Generate XML Schema - Allows you to specify the path of the generated XML Schema file.
  7. Click the SQL Preview button.

    The SQL Query string is editable. You can specify which fields should be taken into consideration.

    If the query string represents a join operation of two or more tables and columns selected from different tables have the same name you should use aliases for them, like the following example. This will avoid the confusion of two columns being mapped to the same name in the result document of the importing operation.

      select s.subcat_id,
            s.nr as s_nr,
            s.name,
            q.q_id,
            q.nr as q_nr,
            q.q_text
        from faq.subcategory s,
                faq.question q
        where  ...
    The input data will be displayed in a tabular form in the Import Settings panel. The XML Import Preview panel will contain an example of what the generated XML will look like.