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, 20 of 22

## Creating Sections in XML Documents that are Document Type Sensitive

Consider an XML document set that contains the <book> tag declared for different document types. You need to create a distinct book section for each document type. Assume that mydocname is declared as an XML document type (root element) as follows:

    <!DOCTYPE mydocname ... [...

Within mydocname, the element <book> is declared. For this tag, you can create a section named mybooksec that is sensitive to the tag's document type as follows:

    begin
    ctx_ddl.create_section_group('myxmlgroup', 'XML_SECTION_GROUP');
    ctx_ddl.add_zone_section('myxmlgroup', 'mybooksec', 'mydocname(book)');
    end;

Note: Oracle8i knows what the end tags look like from the group_type parameter you specify when you create the section group. The start tag you specify must be unique within a section group. Section names need not be unique across tags. You can assign the same section name to more than one tag, making details transparent to searches.

### Repeated Sections

Zone sections can repeat. Each occurrence is treated as a separate section. For example, if <H1> denotes a heading section, they can repeat in the same documents as follows:

    <H1> The Brown Fox </H1>
    <H1> The Gray Wolf </H1>

Assuming that these zone sections are named Heading.

The query:

    WHERE CONTAINS (..., 'Brown WITHIN Heading', ...)...

returns this document.

But the query:

    WHERE CONTAINS (...,' (Brown and Gray) WITHIN Heading',...)...

does not.

### Overlapping Sections

Zone sections can overlap each other. For example, if <B> and <I> denote two different zone sections, they can overlap in document as follows:

    plain <B> bold <I> bold and italic </B> only italic </I>  plain

### Nested Sections

Zone sections can nest, including themselves as follows:

    <TD>
      <TABLE>
      <TD>nested cell</TD>
      </TABLE>
    </TD>

Using the WITHIN operator, you can write queries to search for text in sections within sections.

#### Nested Section Query Example

For example, assume the BOOK1, BOOK2, and AUTHOR zone sections occur as follows in documents doc1 and doc2:

doc1:

    <book1><author>Scott Tiger</author> This is a cool book to read.</book1>

doc2:

    <book2> <author>Scott Tiger</author> This is a great book to read.</book2>

Consider the nested query:

    'Scott WITHIN author WITHIN book1'

This query returns only doc1.

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