Exporting data or tables in XML format

If your data or table contains an XML column or LOB data, you must use the DATAFORMAT=XML clause on the EXPORT DATA or EXPORT TABLE command. This format can also be used when the data or table to be exported does not contain an XML column or LOB data.

Restriction: QMF supports operations with XML data only when you are connected to a database release that supports the XML data type.

When you export data or tables in XML format, the data is exported to the UNIX file, TSO data set, or CICS® data queue that you specify in the command. QMF uses the XML 1.0 specification (fourth edition) when importing and exporting data.

QMF uses z/OS® XML parse services and z/OS Unicode conversion services when processing XML data for export or import, so these services must be configured and active.

All tags shown in the XML examples must be present before you import the XML column data. The tags must be present in the contents of the file, data set, or CICS data queue because QMF uses these tags to parse the file. When QMF encounters the <extensions> tag at the end of the file, the cursor is closed and the import is finished. Modifying or deleting this tag results in an infinite read of the data.

The data is exported as an XML document in Unicode UTF-8 format with a CCSID of 1208. The exported XML data set or CICS data queue consists of header records, records that define the result set, metadata records for each column in the data or table, and data records for each row in the exported data or table.

Header records

The header records in the exported XML file contain the version of XML that is used, the encoding scheme, and the style sheet that is used to format the exported XML document.

The following example shows the type of information that is included in the header records of an exported file:

<?xml version="1.0" encoding="UTF-8" ?> 
  <!-- ?xml-stylesheet type="text/xsl" href="qmf.xslt" ? -->

QMF provides a style sheet that you can use to format your exported XML data. The default style sheet (with the default name qmf.xslt) is supplied as member DSQ1STSH of the QMF samples data set, QMF1310.SDSQSAPn (where n is a national language identifier). Copy this default style sheet to the location of the exported file, then open the XML document to have it formatted to these specifications. If you use a different name for the style sheet, change the header in the exported file to refer to the new style sheet name.

Records that define the result set

The result set definition contains a namespace definition and a schema definition for the QMF schema file that is used with the XML file.

This example shows the records for the result set definition in a sample exported XML file that contains seven columns:
<DataSet xmlns="http://www.ibm.com/QMF" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
  <SourceDescription /> 

    .....Definitions for each column go here.


   .....Data for each row goes here.

<Extensions /> 

Metadata records

The column metadata in the exported XML file consists of the number of columns, column names, column labels (if applicable), data types, data lengths, whether the data is null, and the format.

An example of the metadata for a column called "ID" is shown here. The exported XML file contains one column-description block for each column.
<ColumnDescription id="1">

Data records

The exported XML file contains one row-definition block for each row of exported data. Data records are in variable block spanned (VBS) format.

A <cell> tag identifies each column in the row by number, as shown here for the first row of the Q.STAFF sample table:
<Row id="0">
  <Cell id="1">10</Cell> 
  <Cell id="2">SANDERS</Cell> 
  <Cell id="3">20</Cell> 
  <Cell id="4">MGR</Cell> 
  <Cell id="5">7</Cell> 
  <Cell id="6">99999.99</Cell> 
  <Cell id="7" null="1" /> 
When you use the DATAFORMAT=XML clause on the EXPORT DATA or EXPORT TABLE command and the data contains a column defined with the XML data type, QMF wraps the XML data in CDATA tags. The CDATA tags prevent the parser from trying to process the XML data. Here is an example of how XML data appears in an exported file.
<Row id="0"> 
<Cell id="1">Murphy</Cell>
<Cell id="2">1234</Cell>
<Cell id="3"[CDATA[xml version="1.0" encoding="utf-8"?]]Cell>

How QMF validates the XML

An XML schema document describes the structure of an XML document and defines parameters for the validity of elements and attributes within the XML document.

A default schema file is provided with QMF as member DSQ1SCEM of the QMF samples data set, which is QMF1310.SDSQSAPn (where n is a national language identifier). Copy this member to the directory where the file that contains the XML document is stored. Name the schema document qmf_data.xsd, which is the name for the default schema document under QMF for Workstation and QMF for WebSphere®. You can modify the default schema file according to your business needs for formatting XML data. If you use a name other than qmf_data.xsd or use a different schema file, change the name in any files that reference the schema document.