Java 2EE and XML Development

Скачать в pdf «Java 2EE and XML Development»


XPath expressions can represent a node-set, Boolean, number, or string. They can start from the root element or be relative to a specific position in a document. The most common type of XPath expression is a location path, which represents a node-set. For our product catalog document example, the following XPath represents all the product nodes in the catalog:


/product


XPath has a built-in set of functions that enable you to develop very complex expressions. Although XPath syntax is not a focus of this book, we do explore technologies such as XSLT that use it extensively. Since XPath is so important, we suggest that you become proficient with it as quickly as possible.


You can get more detailed information on XPath at http://www.w3c.org/ TR/xpath.

XPointer


XPointer is an even more specific language that builds on XPath. XPointer expressions point to not only a node-set, but to the specific position or range of positions within a node-set that satisfy a particular condition. XPointer functions provide a very robust method for searching through XML data structures. Take, for example, the following node-set:


<desc>This chapter provides an overview of the J2EE technologies.</desc> <desc>This chapter provides an overview of the XML landscape.</desc> <desc>This chapter is an introduction to distributed systems.</desc>


A simple XPointer expression that operates on this node-set is as follows:


xpointer(string-range(//desc, ‘overview’))


This expression returns all nodes with the name desc that contain the string overview. XPointer expressions can be formed in several ways and can quickly become complex. You can find more information on XPointer at http:// www.w3c.org/XML/Linking.

Скачать в pdf «Java 2EE and XML Development»