Differences between XPointer and Xpath expressions

Hi group,

Following my last action item I was investigating the differences between both specifications, and this is what I came through:

The final conclusion could be something like: "Yes, the xpointer() scheme builds on the top of XPath"

A little bit of background for that conclusion (extracted from the xpointer() Scheme specification [1]):

"It [The Xpointer xpointer() scheme] is based on XPath, and adds the ability to address strings, points, and ranges in accordance with definitions provided in DOM 2: Range."

"The xpointer() scheme is built on top of the XML Path Language [...]. The xpointer() scheme's extensions to XPath add the ability to identify locations that are not single, whole elements (such as those corresponding to typical selections and selection points in some user interfaces), and to combine string matching with the other location methods provided."

"The prototypes for xpointer() scheme functions are given using the same notation used in the XPath Recommendation."

"This specification explicitly extends some aspects of the syntax and semantics of XPath (mainly in relation to support for locations other than whole nodes). Except in such cases, XPath constructs and definitions remain in effect in the xpointer() scheme"

Being the xpointer() Scheme Syntax:

xpointerschemedata ::= Expr

Expr is as defined in the XPath Recommendation, with the extensions defined in this specification.

Details of the XPointer extensions to XPath can be seen at [2]

Taking into consideration all the previous, I think that the best approach is to follow Michael's proposal: XPointer as a subclass of XPath. 

SinglePointer (ptr:reference)
'-ExpressionPointer (ptr:version, ptr:expression)
  '-XPathPointer (ptr:namespace)
    '-XPointerPointer

Namespace (ptr:prefix, ptr:namespaceURI)

Regarding Johannes' concerns about the examples of XPointer that look different from the XPath ones, we can easily build them using the functions referenced at [2]. Some good examples from the specification:

id("chap1")/range-to(id("chap2"))
string-range(//P,"Thomas Pynchon")[3],"P",1,0)

Finally, IMO when representing XPointer pointers, if we decide to focus solely on the xpointer() scheme, we should use only the scheme data for the pointer, as in the following example:

<ptr:XPointerPointer rdf:about="#xPointerPointer">
  <ptr:expression>id("chap1")/range-to(id("chap2"))</ptr:expression>
  <ptr:reference rdf:resource="http://example.org/doc1.html"/>  
</ptr:XPointerPointer>

Instead of using the complete scheme, as in the following one:

<ptr:XPointerPointer rdf:about="#xPointerPointer">
  <ptr:expression>http://example.org/doc1.html#xpointer(id("chap1")/range-to(id("chap2")))</ptr:expression>
  <ptr:reference rdf:resource="http://example.org/doc1.html"/>  
</ptr:XPointerPointer>

This way we avoid any potential consistency problem between the ptr:reference (that is required) and the XPointer uri, and there shouldn't be any problem rebuilding the original expression as it is just: ptr:reference#xpointer(ptr:expression)

[1] - [http://www.w3.org/TR/xptr-xpointer/]
[2] - [http://www.w3.org/TR/xptr-xpointer/#terminology]

Regards,
 CI.

_____________________

Carlos Iglesias

Fundación CTIC
Parque Científico-Tecnológico de Gijón
33203 - Gijón, Asturias, España
teléfono: +34 984291212
fax: +34 984390612
email: carlos.iglesias@fundacionctic.org
URL: http://www.fundacionctic.org 

Received on Tuesday, 1 July 2008 15:15:03 UTC