Oracle Text Reference
Release 9.0.1

Part Number A90121-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to beginning of chapter Go to next page

CONTAINS Query Operators, 10 of 28


INPATH

Use this operator to do path searching in XML documents. This operator is like the WITHIN operator except that the right-hand side is a parentheses enclosed path, rather than a single section name.

Your index must be created with the PATH_SECTION_GROUP for the INPATH operator to work.

Syntax

The INPATH operator has the following syntax:

Top-Level Tag Searching

Syntax  Description 

term INPATH (/A)

term INPATH (A) 

Returns documents that have term within the top-level tags <A> and </A>. The A tag must be a top-level tag, which is the document-type tag. 

Any-Level Tag Searching

Syntax  Description 

term INPATH (//A) 

Returns documents that have term in the <A> tag at any level. This query is the same as 'term WITHIN A

Direct Parentage Path Searching

Syntax  Description 

term INPATH (A/B) 

Returns documents where term appears in a B element which is a direct child of a top-level A element.

For example, a document containing

<A><B>term</B></A>

is returned. 

Single-Level Wildcard Searching

Syntax  Description 

term INPATH (A/*/B) 

Returns documents where term appears in a B element which is a grandchild (two levels down) of a top-level A element.

For example a document containing

<A><D><B>term</B></D></A>

is returned. 

Multi-level Wildcard Searching

Syntax  Description 

term INPATH (A/*/B/*/*/C) 

Returns documents where term appears in a C element which is 3 levels down from a B element which is two levels down (grandchild) of a top-level A element. 

Any-Level Descendant Searching

Syntax  Description 

term INPATH(A//B) 

Returns documents where term appears in a B element which is some descendant (any level) of a top-level A element.  

Attribute Searching

Syntax  Description 

term INPATH (//A/@B) 

Returns documents where term appears in the B attribute of an A element at any level. Attributes must be bound to a direct parent. 

Descendant/Attribute Existence Testing

Syntax  Description 

term INPATH (A[B]) 

Returns documents where term appears in a top-level A element which has a B element as a direct child. 

term INPATH (A[.//B]) 

Returns documents where term appears in a top-level A element which has a B element as a descendant at any level. 

term INPATH (//A[@B]) 

Finds documents where term appears in an A element at any level which has a B attribute. Attributes must be tied to a direct parent. 

Attribute Value Testing

Syntax  Description 

term INPATH (A[@B = "value"]) 

Finds all documents where term appears in a top-level A element which has a B attribute whose value is value.  

term INPATH (A[@B != "value"]) 

Finds all documents where term appears in a top-level A element which has a B attribute whose value is not value.  

Tag Value Testing

Syntax  Description 

term INPATH (A[B = "value"])) 

Returns documents where term appears in an A tag which has a B tag whose value is value

Not

Syntax  Description 

term INPATH (A[NOT(B)]) 

Finds documents where term appears in a top-level A element which does not have a B element as an immediate child. 

AND and OR Testing

Syntax  Description 

term INPATH (A[B and C]) 

Finds documents where term appears in a top-level A element which has a B and a C element as an immediate child. 

term INPATH (A[B and @C="value"]])

 

Finds documents where term appears in a top-level A element which has a B element and a C attribute whose value is value

term INPATH (A [B OR C]) 

Finds documents where term appears in a top-level A element which has a B element or a C element. 

Combining Path and Node Tests

Syntax  Description 

term INPATH (A[@B = "value"]/C/D) 

Returns documents where term appears in aD element which is the child of a C element, which is the child of a top-level A element with a B attribute whose value is value

Nested INPATH

You can nest the entire INPATH expression in another INPATH expression as follows:

(dog INPATH (//A/B/C) INPATH (D)

When you do so, the two INPATH paths are completely independent. The outer INPATH path does not change the context node of the inner INPATH path. For example:

(dog INPATH (A)) INPATH (D)

never finds any documents, because the inner INPATH is looking for dog within the top-level tag A, and the outer INPATH constrains that to document with top-level tag D. A document can have only one top-level tag, so this expression never finds any documents.

Case-Sensitivity

Tags and attribute names in path searching are case-sensitive. That is,

dog INPATH (A)

finds <A>dog</A> but does not find <a>dog</a>. Instead use

dog INPATH (a)

Examples

Top-Level Tag Searching

To find all documents that contain the term dog in the top-level tag <A>:

dog INPATH (/A)

or

dog INPATH(A)

Any-Level Tag Searching

To find all documents that contain the term dog in the <A> tag at any level:

dog INPATH(//A)

This query finds the following documents:

<A>dog</A>

and

<A><B><C>dog</C></B></A>

Direct Parentage Searching

To find all documents that contain the term dog in a B element that is a direct child of a top-level A element:

dog INPATH(A/B)

This query finds the following XML document:

<A><B>My dog is friendly.</B><A>

but does not find:

<C><B>My dog is friendly.</B></C>

Tag Value Testing

You can test the value of tags. For example, the query:

dog INPATH(A[B="dog"])

Finds the following document:

<A><B>dog</B></A>

But does not find:

<A><B>My dog is friendly.</B></A>

Attribute Searching

You can search the content of attributes. For example, the query:

dog INPATH(//A/@B)

Finds the document

<C><A  B="snoop dog"> </A> </C>

Attribute Value Testing

You can test the value of attributes. For example, the query

California INPATH (//A[@B = "home address"])

Finds the document:

<A B="home address">San Francisco, California, USA</A>

But does not find:

<A B="work address">San Francisco, California, USA</A>

Path Testing

You can test if a path exists with the HASPATH operator. For example, the query:

HASPATH(A/B/C)

finds and returns a score of 100 for the document

<A><B><C>dog</C></B></A>

without the query having to reference dog at all.

Limitations

Testing for Equality

The following is an example of an INPATH equality test.

dog INPATH (A[@B = "foo"])

The following limitations apply for these expressions:


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 1996-2001, Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback