Home arrow XML arrow Page 6 - XPointer Basics

A Range Of Options - XML

You already know how to link XML documents together with XLink, and isolate specific nodes or node collections with XPath. Now uncover the third and final piece of the XML linking jigsaw - XPointer, an experimental technology from the W3C, which allows you to create XML links to specific points or ranges within an XML document.

  1. XPointer Basics
  2. The Need For XPointer
  3. Revolving Around An Axis
  4. Proof Of The Pudding
  5. A Fragmented View
  6. A Range Of Options
  7. Asymmetrically Yours
  8. Linking Up
By: icarus, (c) Melonfire
Rating: starstarstarstarstar / 2
December 12, 2001

print this article


To the various node types defined in the XPath specification, XPointer adds two more: points and ranges.

A point is defined as the address of a specific location within an XML document. It is identified by two characteristics: a container node and an index number. The container node is the node which encloses the point, while the index number is an integer which indicates the relative position of the point among the children of the container node.

There are two types of points: node-points, which refer to XML elements, and character-points, which refer to the text contained within XML elements.

The index number within a point definition differs in meaning depending on whether the point is a node-point or a character-point. In the case of a node-point, the index number references a specific child node or nested XML element; in the case of a character-point, it references a particular character of the text string.

Points are defined with XPointer's start-point() and end-point() functions, both of which accept a location path (or collection of location paths) as argument.

A range, defined as the area between two points, is created with the range() function, which returns a collection containing all the elements within the specified range.

An example might help to make this clearer. Consider the following XML document:

<?xml version="1.0"?> <movie id="67" genre="sci-fi"> <title>X-Men</title> <cast>Hugh Jackman, Patrick Stewart and Ian McKellen</cast> <director>Bryan Singer</director> <year>2000</year> <?play_trailer?> </movie>
Now, the XPointer

would return a range covering the / element (the document element) and all those within it - in other words, a range covering the entire document.

The start and end points of this range would be accessible via the XPointers


and would point to the beginning and end of the document respectively.

In a similar manner, the XPointer

would identify the range

while the XPointer

would point to the location immediately preceding the "director" element.

>>> More XML Articles          >>> More By icarus, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Google Docs and Xpath Data Functions
- Flex Array Collection Sort and Filtering
- The Flex Tree Control
- Flex List Controls
- Working with Flex and Datagrids
- How to Set Up Podcasting and Vodcasting
- Creating an RSS Reader Application
- Building an RSS File
- An Introduction to XUL Part 6
- An Introduction to XUL Part 5
- An Introduction to XUL Part 4
- An Introduction to XUL Part 3
- An Introduction to XUL Part 2
- An Introduction to XUL Part 1
- XML Matters: Practical XML Data Design and M...

Developer Shed Affiliates


Dev Shed Tutorial Topics: