Explicitly Specifying the Current Context

If you want to explicitly specify the current context node, place a dot and a forward slash ( ./) in front of the query. This construct typically appears in queries that contain filters . The following two queries are equivalent:

./author 
               
author
               

            

Remember, if you specify the name of an element as a complete query (for example, foo), you obtain only the foo elements that are children of the current context node. You do not necessarily obtain all foo elements in the document.

You can also specify the dot notation ( .) to indicate that you want the XPath processor to manipulate the current context. For example:

//title [. = "History of Trenton"]
               

            

In this example, the XPath processor finds all title elements. The dot indicates the context node. This causes the XPath processor to check each title in turn to determine whether its string value is History of Trenton.

 
Free Stylus Studio XML Training: