When searching the XML document structure, the XML Extender searches element and attribute values that are converted to general data types, but it does not search text. You can use the DB2 UDB Text Extender for structural or full text search on a column that is enabled for XML. The Text Extender supports XML document search in DB2 UDB version 6.1 or higher.
To use the Text Extender search, you must install the DB2 Text Extender and enable your database and tables as described below. To learn how to use the Text Extender search, see the chapter on searching with the Text Extender's UDFs in DB2 Universal Database Text Extender Administration and Programming.
Assuming that you have an XML-enabled database, use the following steps to enable the Text Extender to search the content of an XML-enabled column. For example purposes, the database is named SALES_DB, the table is named ORDER, and the XML column names are XVARCHAR and XCLOB:
'connect to SALES_DB'
From the db2tx command prompt, type:
'enable database'
'enable text column order xvarchar function db2xml.varchartovarchar handle varcharhandle ccsid 850 language us_english format xml indextype precise indexproperty sections_enabled documentmodel (Order) updateindex update'
'enable text column order xclob function db2xml.clob handle clobhandle ccsid 850 language us_english indextype precise updateindex update'
;list of document models [MODELS] modelname=Order ; an 'Order' document model definition ; left side = section name identifier ; right side = section name tag [Order] Order = /Order Order/Customer/Name = /Order/Customer/Name Order/Customer/Email = /Order/Customer/Email Order/Part/@color = /Order/Part/@color Order/Part/Shipment/ShipMode = /Order/Part/Shipment/ShipMode
The Text Extender's search capability works well with the XML Extender document structural search. The recommended method is to create a query that searches on the document element or attributes and uses the Text Extender to search the element content or attribute values.
Example: The following statements search an XML document text with the Text Extender. At the DB2 command window, type:
'connect to SALES_DB' 'select xvarchar from order where db2tx.contains(varcharhandle, 'model Order section(Order/Customer/Name) "Motors"')=1' 'select xclob from order where db2tx.contains(clobhandle, 'model Order section(Order/Customer/Name) "Motors"')=1'
The Text Extender Contains() UDF searches.
This example does not contain all of the steps that required to use the Text Extender to search column data. To learn about the Text Extender search concepts and capability, see the chapter on searching with the Text Extender's UDFs in DB2 Universal Database Text Extender Administration and Programming.