IB_XMLDA 構造体
提供:InterBase
InterBase API を利用した XML の生成 へ戻る
IB_XMLDA 構造体は、ibxml.h ファイルに入っています。 定義は次のとおりです:
typedef struct ib_xmlda {
char ISC_FAR *xmlda_file_name; /* Points to a char string containing
the name of the file used by xml_fetch();
ignored by the buffer function */
char ISC_FAR *xmlda_header_tag; /* Points to the string which is printed
out as the header tag */
char ISC_FAR *xmlda_database_tag; /* Points to the string that is printed
out as the database tag in the xml file*/
char ISC_FAR *xmlda_table_tag; /* Points to the string that is printed
out as the tablename tag in the
xml file */
char ISC_FAR *xmlda_row_tag; /* Points to the string that is printed
out as the rowname tag in the xml file */
FILE *xmlda_file_ptr; /* Used internally by the API to hold the file pointer; can be POINTER type in non-C, C++ programs */ char ISC_FAR **xmlda_temp_buffer; /* Internal use only, used for storing the string array from fetch() */
ISC_STATUS xmlda_fetch_stat; /* Holds the return value from the
isc_dsql_fetch() call; it indicates whether all the records have been redeived or if there is an error */
ULONG xmlda_flags; /* Flags explained below */
ULONG xmlda_more_data; /* Used by the buffer call to maintain the
status of the last record: 0 if there is no more data, 1 if there is data that has been fetched but not put out in the buffer */
ISC_ULONG xmlda_temp_size; /* Internal use only, stores the size of
the last record */
ISC_USHORT xmlda_status; /* Internal status must be set to 0 by user
when called for the first time */
USHORT xmlda_more; /* Used in conjunction with the buffered
mode; set this if there is more XML data */
USHORT xmlda_version; /* Version of XMLDA */
USHORT xmlda_array_size; /* Internal use only */
SLONG xmlda_reserved; /* Reserved for future use */
} IB_XMLDA;
IB_XMLDA 構造体の必須要素
3 つの XML 関数のいずれかを呼び出す前に、次の IB_XMLDA 構造体の要素を設定する必要があります:
- xmlda_file_name は名前で、XML 出力が書き込まれるファイルのフルパスを含む名前です。
isc_dsql_xml_fetch()とisc_dsql_xml_fetch_all()のみ、この名前が必要となります。 - xmlda_version は 1 に設定する必要があります。これは、パーサーが、従来の SQLDA ディスクリプタ領域ではなく、
XSQLDAディスクリプタ領域を使用することを指定します。 - xmlda_status は、
isc_dsql_xml_fetch()が初めて呼び出される際に、0 に設定される必要があります。isc_dsql_fetch_all()では特に効果はありませんが、0 に設定することを推奨します。 これは、ステータスを保持するために、XML 関数が内部的に使用します。
IB_XMLDA 構造体の任意要素
- xmlda_header_tag は、XML ヘッダーとして使用される文字列を指します。 これが NULL に設定されている場合、デフォルト ヘッダーの
<?xml version="1.0">が出力されます。 - xmlda_database_tag は、Database タグの代わりに使用できる文字列を指します (以下の XML ドキュメントの例を参照)。 これが NULL に設定されている場合、XML タグはデフォルトの “Database” になります。
- xmlda_table_tag は、Tablename タグの代わりに使用できる文字列を指します (以下の XML ドキュメントの例を参照)。 これが NULL に設定されている場合、XML タグはデフォルトの “Tablename” になります。
- xmlda_row_tag は、Row タグの代わりに使用できる文字列を指します (以下の XML ドキュメントの例を参照)。 これが NULL に設定されている場合、XML タグはデフォルトの “Row” になります。
- xmlda_flags には現在、次の 2 つの値が設定できます:
XMLDA_ATTRIBUTE_FLAG: XML ドキュメントを、タグではなく属性として生成するXMLDA_NO_NULL_DISPLAY_FLAG: null データとそれに関連するタグを表示しない
- xmlda_file_ptr は、事前に開かれている
FILEポインタに割り当てられる必要があります。ファイルは、書き込むために開かれると想定されます。 関数は、書き込みポインタの場所から書き込みを開始します。 この書き込みポインタの場所は、必要に応じて特定の場所に設定または再設定することができます。 このFILE構造体はいったん関数によって使用されだしたら、変更しないことが推奨されます。 ファイルを閉じるのはプログラマの役目です。
定義
ibxml.h には、利用可能な定義が 3 つあります:
XMLDA_ATTRIBUTE_FLAG1 に設定すると、データを属性として出力します。
#define XMLDA_ATTRIBUTE_FLAG 0x01
XMLDA_NO_NULL_DISPLAY_FLAGnull データを表示しません。
#define XMLDA_NO_NULL_DISPLAY_FLAG 0x02
XMLDA_NO_HEADER_FLAG追加ヘッダーを表示しません。
#define XMLDA_NO_HEADER_FLAG 0x04
XMLDA_ATTRIBUTE_FLAG 出力を、要素ではなく属性として生成します。 このフラグは、InterBase によって生成された実際のデータにのみ影響します。ユーザーは、希望する属性をタグとして入力することで、そのほかのすべてのタグを制御できるからです。
XMLDA_NULL_NO_DISPLAY_FLAG を設定すると、API は null であるデータに対する行の生成をスキップします。 デフォルトの動作では、空の文字列を生成します。