Functions

This section describes the individual functions that enhance XML Services.


tolower and toupper

Description

tolower and toupper return their argument values in lowercase and uppercase, respectively.

Syntax

tolower(string-parameter)
toupper(string-parameter)

Example

This example uses toupper to return the argument value in uppercase.

select xmlextract
('//book[title=”Seven Years in Trenton”]//toupper(first-name)', text_doc) 
from sample_docs where name_doc='bookstore'
----------------------------------------
JOE

normalize-space

Description

Makes two changes when it returns its argument value:

Syntax

normalize-space(string-parameter)

Examples

This example applies normalize-space to a parameter that includes leading and trailing spaces, and embedded newline and tab characters:

select xmlextract
('normalize-space(" Normalize space example. ")', text_doc)
from sample_docs where name_doc='bookstore'
------------------------
Normalize space example.

normalize-space and tolower or toupper are useful in XPath predicates, when you are testing values whose use of white space and case is not known. The following predicate is unaffected by the case and whitespace usage in the title elements:

select xmlextract
('//magazine[normalize-space(tolower(title)="tracking trenton")]//price', 
text_doc)
from sample_docs where name_doc='bookstore'
--------------------------
<price>55</price>

concat

Description

concat returns the string concatenation of the argument values. It has zero or more parameters.

Syntax

concat(string-parameter [,string-parameter]...)

Example

concat can return multiple elements in a single call of xmlextract. For example, the following query returns both first-name and last-name elements:

select xmlextract('//author/concat(first-name, last-name)', text_doc)
from sample_dcs where name_doc='bookstore'
-----------------------------------------
JoeBobMaryBobToniBob

You can also use concat to format and punctuate results. For example:

select xmlextract
('//author/concat(",first(",first-name, ")-last(",last-name, ") ")' , text_doc)
from sample_docs where name_doc='bookstore'
----------------------------------------------
first(Joe)-last(Bob) first(Mary)-last(Bob) first(Toni)-last(Bob)