Using the InterBase API to Generate XML

From InterBase

Go Up to Exporting XML


InterBase provides three API calls for generating XML documents directly from InterBase tables: isc_dsql_xml_fetch(), isc_dsql_xml_fetch_all(), and isc_dsql_xml_buffer_fetch().

These functions are a part of a new client side library called ibxml.dll on Windows and ibxml.so on Solaris and Linux.

  • The structures defined for these functions are located in a new header file called ibxml.h.
  • The prototype definitions are included in the file ibxml_proto.h. This header file also internally includes ibxml.h.

To use this feature, you must to add the library to your link path, and the new header file to your compiler include files.

The new function prototypes are:

  • isc_dsql_xml_buffer_fetch() returns XML-formatted text to the specified buffer.
int isc_dsql_xml_fetch(ISC_STATUS *status_vector,
isc_stmt_handle *stmt_handle,
unsigned short da_version,
char *buffer
int buffer_size
XSQLDA *xsqlda,
IB_XMLDA *ib_xmlda);

In order to use the isc_dsql_xml_buffer_fetch(), you must allocate at least a 1024 character buffer, which is passed to the function in the buffer argument. The buffer_size argument reports the size of this passed buffer. The function returns the size of characters written into the buffer without the terminating null character. It returns –1 if there is not enough memory for it to continue, or –2 if the buffer size is too small to accommodate the complete header or footer. The function does not return incomplete headers, footers, or records. The xmlda_more_data is set if the call should be made once again to get the complete XML buffer.

In order to make the calls work with Delphi, use the regular POINTER type to hold space in the IBXMLDA structure for the FILE * type.

  • isc_dsql_xml_fetch() appends retrieved data to an XML-formatted file and also returns this data to the XSQLDA.
int isc_dsql_xml_fetch(ISC_STATUS *status_vector,
isc _stmt_handle *stmt_handle,
unsigned short da_version,
XSQLDA *xsqlda,
IB_XMLDA *ib_xmlda);
  • isc_dsql_xml_fetch_all() creates an XML-formatted file using a previously prepared and executed statement handle.
int isc_dsql_xml_fetch(ISC_STATUS *status_vector,
isc_stmt_handle *stmt_handle,
unsigned short da_version,
XSQLDA *xsqlda,
IB_XMLDA *ib_xmlda);

These functions work with statements that have been prepared with isc_dsql_prepare() and executed with isc_dsql_execute(). ib_xmlda is a pointer to an initialized XML descriptor area (IB_XMLDA).

isc_dsql_xml_fetch() permits continued access to the data in the cursor, using the XSQLDA.

Blobs and arrays are not supported.

Topics

Advance To: