Loading database(s) from XML documents

The OFBiz WebTools interface provides a number of utilities to help load data, from one or more files and/or directories, into any Entity Engine data source (including databases). In this section, we shall examine loading data from XML document files using the WebTools Entity XML Tools.

Getting ready

Make sure the data to be loaded is formatted correctly as the OFBiz XML Data Import tool requires files to be in XML document format beginning with an entity-engine-xml element tag and ending with the appropriate closing tag as shown:

<entity-engine-xml>
<!-- This is a comment and is valid within a data file -->
<EntityName fieldName="someValue"
anotherFieldName="someOtherValue" />
<!-- You may have as many entity/field declarations as desired
within a single file -->
</entity-engine-xml>

Each XML element within the XML data file represents a record (or row) to be inserted into the indicated entity. Within an element's declaration, each attribute represents a column (or field) within the entity. Attribute names must be valid entity field names. There are many examples of this formatting throughout the code base as this is the format used to construct seed and other data loaded automatically by the ANT data loading directives.

To get started and use the XML Data Import tool, either navigate to the WebTools main web page and select XML Data Import from the main web page menu, or go directly to the tool's URL located at https://localhost:8443/webtools/control/EntityImport. If you have not already logged in, you will be prompted to log in. Enter the administrator's username and password. If these have not changed since initial system download, the administrative user's name is "admin" and the password is "ofbiz".

How to do it...

A database can be loaded from an XML document by following these steps:

  1. To import an XML document file directly to the target data source, enter either the absolute location on the local hard drive (and not a directory location relative from the OFBiz installation directory) of the file or the URL of this file. URLs may be for files local to the OFBiz instance in use or remotely located. Click the Import File button to submit this form. Success and error messages are posted on this web page.
  2. Alternatively, you may insert one or more XML declarations, or cut and paste one or more XML declarations into the provided HTML form's TEXTAREA. Click the Import Text button as shown:
    How to do it...
  3. File imports, if successful, are added to the data source immediately. No need to restart OFBiz.

How it works...

The XML Data Import tool takes one or more well-formed XML document file(s) and copies data from each file as instructed by the XML declarations within the file. Each XML file must contain one or more element(s) that declares the entity to be loaded, as well as element attributes that define the entity fields and the data values to load.

There's more...

When loading files using the XML Data Import tool, care must be taken to load files in the proper order so that foreign-key integrity is preserved. When loading multiple files, loading is sequential and a failure in any file will terminate the loading process and roll back all previously loaded data.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.182.159