Try OpenEdge Now
skip to main content
Working with XML
Reading and Writing XML Data from Temp-Tables and ProDataSets : Writing XML Schema from a temp-table, temp-table buffer, or ProDataSet
 

Writing XML Schema from a temp-table, temp-table buffer, or ProDataSet

The WRITE-XMLSCHEMA( ) method writes an XML representation (an XML Schema document) of the definition for a temp-table, temp-table buffer, or ProDataSet object. The XML Schema is written using the XML Schema Definition (XSD) language.
When writing XML Schema for a temp-table or temp-table buffer object, the AVM writes temp-table and index definitions.When writing XML Schema for a ProDataSet object, the AVM writes all temp-table definitions, index definitions, and data-relations.
Here is the syntax for WRITE-XMLSCHEMA( ). The method returns TRUE or FALSE to indicate whether the operation was successful.

Syntax

WRITE-XMLSCHEMA ( mode, {file|stream |stream-handle|memptr
|handle|longchar} [, formatted[, encoding[, min-xmlschema
[, omit-initial-values]]]] )
target-type
A CHARACTER expression that specifies the target XML Schema document type. Valid values are: "FILE", "STREAM", "MEMPTR", "HANDLE", and "LONGCHAR".
file
A CHARACTER expression that specifies the name of a file to which the AVM writes the XML Schema document text. You can specify an absolute pathname or a relative pathname (based on the current working directory). If a file with the specified name already exists, the AVM verifies that the file is writable and overwrites the file.
stream
A CHARACTER expression that specifies the name of a stream. If you specify the empty string (""), the AVM writes the XML Schema document text to the default unnamed output stream.
memptr
A MEMPTR variable to contain the XML Schema document text. The method allocates the required amount of memory for the XML document text and sets the size of the variable. When you are finished using the MEMPTR, you must free the associated memory by executing SET-SIZE(memptr) = 0 on the MEMPTR.
handle
An X-document object handle or X-noderef object handle. If the specified handle contains XML text, the AVM deletes the existing text first.
longchar
A LONGCHAR variable to contain the XML Schema document text.
The AVM saves the XML Schema document text to the LONGCHAR variable in the code page that corresponds to the character encoding you specify in the encoding option. If you do not specify a character encoding for the XML Schema document text, the AVM saves the LONGCHAR variable in UTF-8.
If the LONGCHAR variable's code page is fixed (that is, set using the FIX-CODEPAGE function) and the fixed code page is not equivalent to the character encoding you specify in the encoding option, the WRITE-XMLSCHEMA( ) method returns an error and the XML Schema document is not saved to the LONGCHAR.
formatted
An optional LOGICAL expression where TRUE directs the AVM to format the XML Schema document text in a hierarchical manner using extra white space, carriage returns, and line feeds. The default value is FALSE.
If you specify the Unknown value (?), the method uses the default value of FALSE.
encoding
An optional CHARACTER expression that specifies the name of the character encoding the AVM uses to write the XML Schema document text. The default encoding is UTF-8.
The encoding name must be an Internet Assigned Numbers Authority (IANA) name supported by the ABL XML parser. For a list of supported IANA encodings and their corresponding ABL code pages, see ABLto IANA Code Page Mappings.
Note: The AVM records this character encoding in the encoding declaration in the XML document's prologue. If you specify the empty string ("") or the Unknown value (?), The AVM uses the default encoding of UTF-8. In this case, The AVM does not record the character encoding in the XML document's encoding declaration.
If target-type is HANDLE, the X-document's ENCODING attribute is also set to UTF-8.
min-xmlschema
An optional LOGICAL expression where TRUE directs the AVM to write the minimum amount of XML Schema for the object, and FALSE directs the AVM to write the complete XML Schema including ABL-specific XML Schema extensions. The default value is FALSE. If you specify the Unknown value (?), the method uses the default value of FALSE.
When TRUE, most ABL-specific XML Schema information is omitted from the XML Schema. For a complete list of ABL XML Schema extensions, see Using XML Schema. If the ABL data type of the temp-table field is not the default ABL data type for the XML Schema type, the AVM writes the prodata:dataType XML Schema attribute for the field. If the initial value of the temp-table field is TODAY, NOW, or UNKNOWN (and UNKNOWN is not the default initial value for the field's data type), the AVM writes the prodata:initial XML Schema attribute for the field.
When TRUE, the XML Schema will contain any ABL-specific XML Schema attributes needed to define the data relations for a ProDataSet.
omit-initial-values
An optional LOGICAL expression where TRUE directs the AVM to exclude temp-table fields containing their initial values from the XML document, and FALSE directs the AVM to include all temp-table field data in the XML. The default value is FALSE. If you specify the Unknown value (?), the method uses the default value of FALSE.
Note: For an array field to be omitted, each element of the array must contain the initial value.
See Examplesof additional XML support for more information.
* Writing a temp-table definition to XML Schema
* Writing a ProDataSet definition to XML Schema files