here( )

The here( ) function is only used inside XML documents. It refers to the node that contains the XPointer or, if the node that contains the XPointer is a text node, the element node that contains that text node. here( ) is useful in relative links. For example, these navigation elements link to the page elements preceding and following the pages in which they’re contained:

<page>
  content of the page...
  <navigation xlink:type="simple"
    xlink:href="#xpointer(here( )/../../preceding-sibling::page[1])">
    Previous
  </navigation>
  <navigation xlink:type="simple"
    xlink:href="#xpointer(here( )/../../following-sibling::page[1])">
    Next
  </navigation>
</page>

In these elements, the here( ) function refers to the xlink:href attribute nodes that contain the XPointer. The first .. selects the navigation parent element. The second .. selects its parent page element, and the final location step selects the previous or next page element.

Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.