The XML column API entity represents an XML column in an ArcSDE table.
An XML column
contains references to associated XML data, which is stored in several internal
tables. These tables are created and managed by ArcSDE and store associated XML
data such as Indexes, Tags, and Docs.
The database schema shows the XML
columns association with the internal tables such as the SDE_XML_Columns table,
the SDE_XML_INDEXES table, the SDE_XML_Doc<ID> table, and the SDE_XML_IDX<ID>
table.
In the Java API, the XML column is represented by the SeXmlColumn class while
the C API provides several functions (SE_xml_column* and SE_xml_columninfo*) to use an XML column and retrieve and set
its attribute values.
The following shows how an XML column is created, retrieved from the database,
and deleted through the ArcSDE C and Java APIs.
Step 1: Create a table
Step 2: Create the XML column object and add it to the table.
LONG rc, in_types[5], i;
SE_COLUMN_DEF column_defs[num_columns];
CHAR tableName[SE_QUALIFIED_TABLE_NAME], index_name[SE_QUALIFIED_XML_INDEX_LEN],
*in_names[5], *config_keyword[10];
SE_XMLINDEXINFO xml_index;
BOOL buffered, has_xml;
SE_XMLTAGINFO tag;
SE_XMLCOLUMNINFO xmlcolumn;
rc = SE_table_create(connection, tableName, num_columns, column_defs, config_keyword);
/* Create an index definition for the column */
rc = SE_xmlindexinfo_create (&xml_index);
sprintf(index_name, "xml_index");
rc = SE_xmlindexinfo_set_name (xml_index, index_name);
rc = SE_xmlindexinfo_set_type (xml_index, SE_XML_INDEX_DEFINITION);
in_names[0] = "/metadata/demo/gn/suptheme";
in_names[1] = "/metadata/demo/gn/coverage";
in_names[2] = "/metadata/demo/gn/featured";
in_names[3] = "/metadata/demo@MetaID";
in_types[0] = SE_XML_INDEX_DOUBLE_TYPE;
in_types[1] = SE_XML_INDEX_STRING_TYPE;
in_types[2] = SE_XML_INDEX_STRING_TYPE;
in_types[3] = SE_XML_INDEX_DOUBLE_TYPE;
rc = SE_xmltaginfo_create (&tag);
for (i = 0; i < 4; i++){
rc = SE_xmltaginfo_set_name (tag, in_names[i]);
rc = SE_xmltaginfo_set_data_type (tag, in_types[i]);
rc = SE_xmlindexinfo_add_tag (xml_index, tag);
}
/* Create xml column */
rc = SE_xmlcolumninfo_create (&xmlcolumn);
rc = SE_xmlcolumninfo_set_xml_column (xmlcolumn, tableName, XMLCOL);
rc = SE_xmlcolumninfo_set_creation_keyword (xmlcolumn, "DEFAULTS");
rc = SE_xmlcolumninfo_set_minimum_id (xmlcolumn, 500);
rc = SE_xmlcolumninfo_set_index (xmlcolumn, xml_index);
rc = SE_xmlcolumn_create (handle, xmlcolumn);
SeConnection conn = ...
SeTable table = createTable();
int[] in_types = new int[5];
String[] in_names = new String[5];
//Create XML Index
SeXmlIndex index = new SeXmlIndex(conn);
index.setName("xml_index");
index.setDescription("index description");
index.setType(SeDefs.SE_XML_INDEX_DEFINITION);
in_names[0] = "/metadata/demo/gn/suptheme";
in_names[1] = "/metadata/demo/gn/coverage";
in_names[2] = "/metadata/demo/gn/featured";
in_names[3] = "/metadata/demo@MetaID";
in_types[0] = SeDefs.SE_XML_INDEX_DOUBLE_TYPE;
in_types[1] = SeDefs.SE_XML_INDEX_STRING_TYPE;
in_types[2] = SeDefs.SE_XML_INDEX_STRING_TYPE;
in_types[3] = SeDefs.SE_XML_INDEX_DOUBLE_TYPE;
//Create tags
SeXmlTag tag = new SeXmlTag();
for (int i = 0; i <4; i++)<br> {
tag.setName(in_names[i]);
tag.setDataType(in_types[i]);
index.addTag(tag);
}
//Create XML Column
SeXmlColumn xmlCol=new SeXmlColumn(conn);
xmlCol.setXmlColumn(tableName, xmlColumnName);
xmlCol.setCreationKeyword("DEFAULTS");
xmlCol.setMinimumId(100);
xmlCol.setIndex(index);
xmlCol.create();
|
LONG rc, min_id;
SE_XMLINDEXINFO xml_index;
BOOL buffered, has_xml;
SE_XMLCOLUMNINFO xml_column;
CHAR kwd[256], tableName[10], columnName[10];
rc = SE_xmlcolumninfo_create (&xml_column);
rc = SE_xmlcolumn_get_info (handle, tableName, xmlColumnName, xmlcolumn);
rc = SE_xmlcolumninfo_get_minimum_id (xml_column, &min_id);
rc = SE_xmlcolumninfo_get_creation_keyword(xml_column, kwd);
rc = SE_xmlindexinfo_create (&xml_index);
rc = SE_xmlcolumninfo_get_index (xmlcolumn, xml_index);
printf("\nXML Column: ");
printf("\n Column Name %s", xmlColumnName");
printf("\n Minimum Id: %d", temp_long);
printf("\n Table Name: %s", tableName);
printf("\n Creation Keyword: %s", kwd);
if(col.hasIndex())
{
//See XML Index page in API Entities
printIndexInfo(col.getIndex());
}
SE_xmlcolumninfo_free (xml_column);
SE_xmlindexinfo_free (xml_index);
SeXmlColumn col = ...;
String xmlColInfo[] = col.getXmlColumn();
String hasIndex = null;
System.out.println("\nXML Column: " +
"\n Column Name: " + xmlColInfo[1] +
"\n Minimum Id: " + col.getMinimumId() +
"\n Table Name: " + xmlColInfo[0] +
"\n Creation Keyword: " + col.getCreationKeyword());
if (col.hasIndex())
{
//See XML Index page in API Entities
printIndexInfo(col.getIndex());
}
|
LONG rc;
SE_REGINFO reginfo;
BOOL has_xml;
rc = SE_xmlcolumn_delete(handle, tableName, xmlcolumn);
rc = SE_registration_get_info(handle, table, reginfo);
has_xml = SE_reginfo_has_xml(reginfo);
if(has_xml)
{
printf("Registration shows an xml col after deleting it.\n");
}
SeConnection conn = ...
SeTable table = createTable();
SeXmlColumn xmlCol= ....;
..
..
..
try
{
xmlCol.delete(tableName, xmlColumnName);
}
catch(SeException se)
{
se.printStackTrace();
}
|
|