The XPath “//” operator represents an arbitrary number of arbitrary steps. Thus, these two query expressions are equivalent:
/bookstore//first-name
/bookstore/(* | */* | */*/* | */*/*/* | */*/*/*/* )/first-name
In Adaptive Server 12.5.2, the interpretation of the “//” operator has changed to reflect the XPath standard.
Consider a predicate intended to return the title of each book whose author’s first name is “Mary.” You could write this query like this:
(a) /bookstore/book[author/first-name = "Mary"]/title
In Adaptive Server 12.5.1, you could also reference first-name in the predicate using the “//” operator as follows:
(b) /bookstore/book[//first-name = "Mary"]/title
Adaptive Server 12.5.1 interpreted the leading “//” operator as a relative reference to all first-name elements contained in the current book element.
The XPath standard, however, specifies that a leading “//” operator is an absolute reference that references every first-name element in the entire document. To reference the first-name elements contained in the current book, you must precede the “//” operator with the "." operator to indicate the current context:
(c) /bookstore/book[.//first-name = "Mary"]/title
Adaptive Server 12.5.2 adopts the XPath standard interpretation of the “//” operator. Queries that were written in form (b) with Adaptive Server 12.5.1 should be written in form (c) with Adaptive Server 12.5.2.
Queries written in form (b) with Adaptive Server 12.5.2 will raise an exception:
select xmlextract( '/bookstore/book[//first-name = "Mary"]/title', text_doc) from sample_docs where name_doc='bookstore' ---------------------------------------------------- Msg 14833, Level 16, State 0: Line 1: Absolute paths inside a filter operator are not supported.
You should write such a query in the ASE 12.5.2 form, that is, form (c):
select xmlextract( '/bookstore/book[.//first-name ="Mary"]/title’, text_doc) from sample_docs where name_doc='bookstore' --------------------------------------------------- <title>History of Trenton</title>
Copyright © 2004. Sybase Inc. All rights reserved. |
![]() |