Oracle8i Application Developer's Guide - XML Release 3 (8.1.7) Part Number A86030-01 |
Library | Service | Contents | Index

Using interMedia Text to Search and Retrieve Data from XML Documents, 18 of 22

## 2 Set the Preference's Attributes

To set the preference's attributes for XML_SECTION_GROUP, use the following procedures:

- Add_Zone_Section

- Add_Attr_Section

- Add_Field_Section

- Add_Special_Section

To set the preference's attributes for AUTO_SECTION_GROUP, use the following procedures:

- Add_Zone_Section

- Add_Attr_Section

- Add_Field_Section

There are corresponding CTX_DDL.drop sections and CTX_DDL.remove section syntax.

### 2.1 Using CTX_DDL.add_zone_section

The syntax for CTX_DDL.add_zone_section follows:

    CTX_DDL.Add_Zone_Section (
     group_name      => 'my_section_group' /* whatever you called it above */
     section_name    => 'author' /* what you want to call this section */
     tag             => 'my_tag' /* what represents it in XML */ );

where 'my_tag' implies opening with <my_tag> and closing with </my_tag>.

#### add_zone_section Guidelines

add_zone_section guidelines are listed here:

- Call CTX_DDL.Add_Zone_Section for each tag in your XML document that you need to search on.

### 2.2 Using CTX_DDL.Add_Attr_Section

The syntax for CTX_DDL.add_attr_section follows:

    CTX_DDL.Add_Attr_Section ( /* call this as many times as you need to describe
                                 the attribute sections */
     group_name      => 'my_section_group' /* whatever you did call it above */
     section_name    => 'author' /* what you want to call this section */
     tag             => 'my_tag' /* what represents it in XML */ );

where 'my_tag' implies opening with <my_tag> and closing with </my_tag>.

#### add_attr_section Guidelines

add_attr_section guidelines are listed here:

- Consider meta_data attribute author:

  <meta_data author = "John Smith" title="How to get to Mars">

The more sections you add to your index, the longer your search will take.

add_attr_section adds an attribute section to an XML section group. This procedure is useful for defining attributes in XML documents as sections. This allows you to search XML attribute text with the WITHIN operator.

The section_name:

- Is the name used for WITHIN queries on the attribute text.

- Cannot contain the colon (:) or dot (.) characters.

- Must be unique within group_name.

- Is case-insensitive.

- Can be no more than 64 bytes.

The tag specifies the name of the attribute in tag@attr format. This is case-sensitive.

Note: In the add_attr_section procedure, you can have many tags all represented by the same section name at query time. Explained in another way, the names used as the arguments of the keyword WITHIN can be different from the actual XML tag names. That is many tags can be mapped to the same name at query time. This feature enhances query usability.

### 2.3 Using CTX_DDL.add_field_section

The syntax for CTX_DDL.add_field_section follows:

    CTX_DDL.Add_Field_Section (
     group_name     => 'my_section_group' /* whatever you called it above */
     section_name   => 'qq' /* what you want to call this section */
     tag            => 'my_tag' /* what represents it in XML */ );
     visible        => TRUE or FALSE );

#### add_field_section Guidelines

add_field_section guidelines are listed here:

- add_field_section and add_zone_section attributes differ in performance.

- In a document, tags can be repeated two or more times, however some tags, such as "title", occur only once. A DTD (or XML Schema) define how many times the tags occur.

- Visible attribute: This is available in add_field_section but not available in the add_zone_section. If VISIBLE is set to TRUE then a query such as "... CONTAINS cat... becomes irrelevant if cat occurs in title or paragraph.

  Consider again the query, "... CONTAINS cat...". You may not get a hit if you use VISIBLE=TRUE. If VISIBLE=FALSE, the index will be smaller. You may lose some functionality but your performance will be improved, compared to if you set VISIBLE =TRUE.

  - If you set up your index using the add_zone_section....

  - If you set up your index using the add_field_section....

    Note: Constructing an index is harder if you have to cater for the fact that there could be more than one occurrence of any one tag. If the tag in your XML document occurs only once, use the single add_field_section procedure. For example, ".... CONTAINS cat and dog WITHIN title...... If the tag in your XML document occurs more than once, use the add_zone_section procedure. For example, ".... CONTAINS cat and dog WITHIN paragraph....". This has many possibilities.

#### How Attr_Section Differs From Field_Section

Attribute section differs from field section in the following ways:

- Attribute text is considered invisible, though, so the following:

      WHERE CONTAINS (..., '... jeeves',...)...

  does NOT find the document, somewhat like field sections. Unlike field sections, however, attribute section within searches can distinguish between occurrences. Consider the document:

        <comment author="jeeves">
          I really like interMedia Text
        </comment>
        <comment author="bertram">
          Me too
        </comment>

  the query:

      WHERE CONTAINS (...,'(cryil and bertram) WITHIN author', ...)...

  will NOT find the document, because "jeeves" and "bertram" do not occur within the SAME attribute text.

- Attribute section names cannot overlap with zone or field section names, although you can map more than one tag@attr to a single section name. Attribute sections do not support default values. Given the document:

        <!DOCTYPE foo [
          <!ELEMENT foo (bar)>
          <!ELEMENT bar (#PCDATA)>

            <!ATTLIST bar
              rev CDATA "8i">

        ]>
        <foo>
          <bar>whatever</bar>
        </foo>

  and attribute section:

        ctx_ddl.add_attr_section('mysg','barrev','bar@rev');

  the query:

  8i within barrev does not hit the document, although in XML semantics, the "bar" element has a default value for its "rev" attribute.

### 2.4 Using CTX_DDL.add_special_section

The syntax for CTX_DDL.add_special_section follows:

    CTX_DDL.Add_Special_Section (
     group_name     => 'my_section_group' /* whatever you called it above */
     section_name   => 'qq' /* what you want to call this section */ );

#### add_special_section Guidelines

add_special_section guidelines are listed here:

Here the tag option is not present. A section not defined with an open and close tag has an implicit definition.Use this section when your document is composed, for example, of mostly non-tagged sentences and paragraphs that you need to search. These are explicitly defined.

For example, if your query could be "... CONTAINS cat and dog WITHIN sentence"...

### 2.5 Using CtX_DDL.Add_Stop_Section

    CtX_DDL.Add_Stop_Section (
     group_name     => 'my_section_group' /* whatever you called it above */
     section_name   => 'qq' /* what you want to call this section */ );

| Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
Library | Service | Contents | Index