XPointer scheme is an addition of few more functions to the XPath expressions. Concepts such as location, location types, location sets, points and ranges are added to the XPointer scheme.

  • Location is a combination of a node, a range, a points.
  • Location type is a node type or a point type or a range type.
  • Location sets are node sets as explained in XPath. Point and range are non-node locations.
  •  Point is the position in the document. It can be node which contains point or it can be a positive number which represents the offset among child nodes or container node. The nodes can be text, comment, attribute, PI.
  • Range is the XML structure between starting and ending points. Range must have same container node for start and end points. Example, if the range starts with text node, it has to end with text node only. If the start point is equal to end point the range is called collapsed range.

Range functions

The range()

The range() function returns ranges covering locations in location-set passed as argument to function. For each location in the location-set passed as input a range is added to the resultant location set.

Syntax for the range() function

location-set range(location-set)

The range-inside()

The range-inside() function returns ranges covering the contents of locations in location-set passed as argument to function. For each location in the location-set passed as input a range is added to the resultant location set.

Syntax for the range-inside() function

location-set range-inside(location-set)

The start-point()

The start-point() function takes location-set as input parameter and returns start point for each location. If the location is point of type root, element, text, comment, PI, the index of start point is 0.

Syntax for the start-point() function

location-set start-point(location-set)

The end-point()

The end-point() function takes location-set as input parameter and returns end point for each location. If the location is point of type root, element, the index of end point is number of children of end-point location. If location is text, comment, PI, the end point is length of string- value of location.

Syntax for the end-point() function

location-set end-point(location-set)

The here()

The here() function returns a location-set with single member. If the evaluated expression is text node of an element node, the location returned is element node. Else the evaluated XPointer is returned as location.

Syntax for the here() function

location-set here()

The origin()

The origin() function is used when the link is not in the source document. This method addresses third party and in-bound links as in XLink. It returns the location from which the link traversal began.

Syntax for the origin() function

location-set origin()

The range-to()

The range-to() function takes the location-set as input and returns a range. The expression in the argument is evaluated and the start and end of the location is returned.

Syntax for the range-to() function

location-set range-to(location-set)

The string-range()

The string-range() function for each location in the location-set argument this method returns a range for each match of the search string.

Syntax for the string-range() function

location-set string-range(location-set, string, number, number)

where:

  • string - string to be searched.
  • number - first argument gives position of the first character to be in resulting range.
  • number – second argument gives the number of characters in the range.

 

›› go to examples ››