Attribute Searching
You can search XML attribute text in one of two ways:
-
Creating Attribute Sections
Create attribute sections with
CTX_DDL.ADD_ATTR_SECTIONand then index withXML_SECTION_GROUP.If you useAUTO_SECTION_GROUPwhen you index, attribute sections are created automatically. You can query attribute sections with theWITHINoperator.Consider an XML file that defines the
BOOKtag with aTITLEattribute:<BOOK TITLE="Tale of Two Cities"> It was the best of times. </BOOK>To define the title attribute as an attribute section, create an
XML_SECTION_GROUPand define the attribute section:begin ctx_ddl.create_section_group('myxmlgroup', 'XML_SECTION_GROUP'); ctx_ddl.add_attr_section('myxmlgroup', 'booktitle', 'book@title'); end;To index:
CREATE INDEX myindex ON xmldocs(xmlfile) INDEXTYPE IS ctxsys.context PARAMETERS ('datastore ctxsys.default_datastore filter ctxsys.null_filter section group myxmlgroup' );To query the booktitle XML attribute section:
'Cities within booktitle' -
Searching Attributes with the INPATH Operator
Index with the
PATH_SECTION_GROUPand query attribute text with theINPATHoperator.
See Also: “Path Section Searching”