[annotator-dev] annotator / xpath-range bug

Hari G hari_g at hotmail.com
Tue Feb 16 18:29:29 UTC 2016




Hello All:
Looks like this a dead mailing list... anyway I will ask...
#1 I looked everywhere for the xpath-range code. The github repo https://github.com/openannotation/xpath-range and npm package has different code. The real location of the xpath-range source would be helpful.
#2 The toNode method has a bug. # Public: Finds an Element Node using an XPath relative to the document root.## If the document is served as application/xhtml+xml it will try and resolve# any namespaces within the XPath.## path - An XPath String to query.## Examples##   node = toNode('/html/body/div/p[2]')#   if node#     # Do something with the node.## Returns the Node if found otherwise null.toNode = (path, root = document) ->
It will not find the node if the attribute selector has / or : in it. Example:
toNode("//p[@resource='http://purl.org/pearson/asset/adb19cb3a588ab58cbc0db272048aed6d60a29db5']") and toNode("//p[@resource='asset:adb4afbb2c91461765201bd8eb32f54aad1bb3800']") will not work. However toNode("//p[@resource='adb4afbb2c91461765201bd8eb32f54aad1bb3800']") works.

The problem is with the following code (line 161 in xpath.coffee):      path = (for segment in path.split '/'        if segment and segment.indexOf(':') == -1          segment.replace(/^([a-z]+)/, 'xhtml:$1')        else segment      ).join('/')
This will convert the //p[@resource='http://purl.org/pearson/asset/adb19cb3a588ab58cbc0db272048aed6d60a29db5'] into //xhtml:p[@resource='http://xhtml:purl.org/xhtml:pearson/xhtml:asset/xhtml:adb19cb3a588ab58cbc0db272048aed6d60a29db5'] instead of converting to //xhtml:p[@resource='http://purl.org/pearson/asset/adb19cb3a588ab58cbc0db272048aed6d60a29db5']
I have never worked on coffee script and it took me a while to find the coffee script... by that time I made a code change to the generated code to fix the issue I am facing... Here is the screenshot of diff (which may not be useful):http://content.screencast.com/users/harinair/folders/Jing/media/fac08329-05bf-4b51-8bba-cea25913dc15/00000064.png
I can add this as a bug in github but I am not sure which github repo to add this bug to. I can also help in coding/testing if someone can give me some pointers.
Hari Gangadharan

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/annotator-dev/attachments/20160216/442627d5/attachment-0003.html>


More information about the annotator-dev mailing list