XML publishing

XML publishing provides a way to transform results of SQL queries into XML structures.

When you publish an XML document using the built-in XML publishing functions, you transform the result set of an SQL query into an XML structure, optionally including an XML schema and header. You can store the XML in the database server for use in XML-based applications.

The input XML must be in nested elements within an XML document, with each column being an XML element rather than an attribute. This format is sometimes called the FOR XML AUTO, ELEMENTS format.

The genxmlschema function and other XML publishing functions cannot publish BYTE or TEXT columns into an XML document. These functions take the input column as ROW types and then publish them. BYTE and TEXT are not allowed in ROW types, so cannot be used in these publishing functions.

ROW types are unsupported in distributed queries. These functions use ROW types. As a result, these publishing functions cannot be used in distributed queries or use a synonym referring to a non-local object.

The Scheduler must be running in the database server. If the Scheduler is not running when you run an XML function, a message that the function is not found is returned.

The database against which you run the XML functions must meet the following requirements:

  • The database must be logged.
  • The database must not be defined as an ANSI database.

If you attempt to run an XML function in an unlogged or ANSI database, the message DataBlade registration failed is printed in the database server message log.

Before you run XML functions, run the following statement to allow multiple lines:
EXECUTE PROCEDURE ifx_allow_newline('t'); 
Run the following statements on the database server before running the examples in this book. The CREATE DATABASE statement uses a dbspace named datadbs. You must either create a dbspace named datadbs or substitute datadbs with the name of an existing dbspace.
EXECUTE PROCEDURE ifx_allow_newline('t');
CREATE DATABASE demo_xml IN datadbs with log;
CREATE TABLE tab (col2 lvarchar);
INSERT INTO tab VALUES ('
	<personnel>
		<person id="Jason.Ma">
		<name>
		  <family>Ma</family>
  		<given>Jason</given>
		</name>
		</person>
	</personnel>');