Example 4  Example 6

Chapter 2: XML Services

Example 5

String functions operate on the text of their parameters. This is an implicit application of text(). For example, this query returns a first-name element as an XML fragment:

select xmlextract
( '//book[title="Seven Years in Trenton"]//firstname’, text_doc)
from sample_docs where name_doc='bookstore'-----------------------------<first-name>Joe</first-name>

The following query returns the text of that first-name XML fragment:

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

The next query applies tolower to the first-name element. This function operates implicitly on the text of the element:

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

This has the same effect as the next example, which explicitly passes the text of the XML element as the parameter:

select xmlextract
( '//book[title="Seven Years in Trenton"]//tolower(first-name/text())',  
text_doc) 
from sample_docs where name_doc='bookstore'---------------------------------------joe 




Copyright © 2004. Sybase Inc. All rights reserved. Example 6

View this book as PDF