Examples: Index XML attributes

These examples are based on the following three rows of data:
<boat><name reg="hmc">titanic</name></boat>

<airplane callsign="qofz">kittyhawk</airplane>

<boat><name reg="CAN">Spirit of Canada</name></boat>

Example 1: Compare all_xmltags and all_xmlattrs

The following CREATE INDEX statement uses the all_xmltags parameter:
CREATE INDEX bts_idx ON bts_100_tab(col2 bts_nvarchar_ops) 
       USING bts(all_xmltags="yes") IN bts_sbspace1 ;
The index has these fields representing the type of tag:
airplane
name
By contrast, the following CREATE INDEX statement uses the all_xmlattrs parameter instead of the all_xmltags parameter:
CREATE INDEX bts_idx ON bts_100_tab(col2 bts_nvarchar_ops) 
       USING bts(all_xmlattrs="yes") IN bts_sbspace1 ;
The index has these fields representing the attributes of the tags:
@callsign
@reg

Example 2: Combine all_xmlattrs and all_xmltags

The following CREATE INDEX statement uses both the all_xmlattrs and the all_xmltags parameters:
CREATE INDEX bts_idx ON bts_100_tab(col2 bts_nvarchar_ops) 
       USING bts(all_xmlattrs="yes",
                 all_xmltags="yes") IN bts_sbspace1 ;
The index has these fields representing both the types of tags and the tag attributes:
@callsign
@reg
airplane
name

Example 3: Combine all_xmlattrs, all_xmltags, and xmlpath_processing

The following CREATE INDEX statement uses the all_xmlattrs, the all_xmltags, and the xmlpath_processing parameters:

CREATE INDEX bts_idx ON bts_100_tab(col2 bts_nvarchar_ops) 
        USING bts(xmlpath_processing="yes",
                  all_xmlattrs="yes",
                  all_xmltags="yes") IN bts_sbspace1 ;
The index has these fields, representing the full paths of the tags and attributes:
/airplane
/airplane@callsign
/boat/name
/boat/name@reg

Example 4: Comparing all_xmltags to all_xmlattrs along with xmlpath_processing

The following CREATE INDEX statement uses the all_xmltags parameter with the xmlpath_processing parameter:
CREATE INDEX bts_idx ON bts_100_tab(col2 bts_nvarchar_ops) 
        USING bts(xmlpath_processing="yes",
                  all_xmltags="yes") IN bts_sbspace1 ;
The index has these fields, representing the paths of the tags:
/airplane
/boat/name
The following CREATE INDEX statement uses the all_xmlattrs parameter with the xmlpath_processing parameter:
CREATE INDEX bts_idx ON bts_100_tab(col2 bts_nvarchar_ops) 
        USING bts(xmlpath_processing="yes",
                 all_xmlattrs="yes") IN bts_sbspace1 ;
The index has these fields, representing the paths of the attributes:
/airplane@callsign
/boat/name@reg