This section describes the individual functions that enhance XML Services.
tolower and toupper return their argument values in lowercase and uppercase, respectively.
tolower(string-parameter)
toupper(string-parameter)
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
Makes two changes when it returns its argument value:
It removes leading and trailing white-space characters.
It replaces all substrings of two or more white-space characters that are not leading characters with a single white-space character.
normalize-space(string-parameter)
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 returns the string concatenation of the argument values. It has zero or more parameters.
concat(string-parameter [,string-parameter]...)
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)
Copyright © 2005. Sybase Inc. All rights reserved. |
![]() |