Solved

bug in processing XPATH with this simple regular expression?

Posted on 2013-06-16
13
359 Views
Last Modified: 2013-06-24
Take this input:
<div id="ps-content">foobar</div>

and apply this XPATH 2+:
//div[matches(@id,"^s-content$")]

I tried with BaseX and it matched!  despite the fact that "^" in regex language means "the start of the string".

Why does it match?
0
Comment
Question by:lucavilla
  • 7
  • 5
13 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 39251883
I can't answer why it matches

I can confirm it should not match
and using Saxon, it rightfully does not match

I suggest you report it to BaseX as a bug to look into, because a bug it is
0
 

Author Comment

by:lucavilla
ID: 39252297
Thanks for testing it with Saxon!

I now also tested it with Xidel too and it correctly doesn't match,  while it matches if I add the "p".

Do you know where is the right place to report the bug?
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 39252303
I did not find any bugtracker tool on the site
(I was at an XML conference this weekend in London and actually was surprised not to meet any of the basex guys there, I could have asked)
anyway, you could try baseX talk
basex-talk(at)mailman.uni-konstanz(dot)de.
0
 

Author Comment

by:lucavilla
ID: 39254450
Done, I reported the bug to that email (mailing list): https://mailman.uni-konstanz.de/pipermail/basex-talk/2013-June/005241.html

Let's see what they say...

PS: wow, an XML conference, interesting!
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 39254526
yeah, well actually it was pretty interesting

http://xmllondon.com/
a whole weekend, me and the other nerds :-)
0
 

Author Comment

by:lucavilla
ID: 39254574
I read the program at http://xmllondon.com/programme.jsp
Really interesting!
Too bad that I'm so far... being in Italy...
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Accepted Solution

by:
lucavilla earned 0 total points
ID: 39268339
Solved.
The cause turned out to be Windows (7) command-line related.
If I put the XPATH in a file it works correctly!
0
 

Author Comment

by:lucavilla
ID: 39269026
I've requested that this question be closed as follows:

Accepted answer: 0 points for lucavilla's comment #a39268339

for the following reason:

Solution found by experimenting
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 39269027
If you want to accept your own answer (a bit inappropriate here actually) make sure it contains a solution. 'win 7 command-line related' is too vague.

Note I confirmed it is a bug and it should not return values, that on its own is an acceptable reassurance

What did baseX reply? What exactly is the command-line related issue? How can your accepted answer help others that run in the same issue?
If you pasted the XPath in a file and it works ... it still could be a baseX issue, them doing the wrong thing with windows command lines. Still they should look into it. I can imagine that they parse out the command line the wrong way
0
 

Assisted Solution

by:lucavilla
lucavilla earned 0 total points
ID: 39269439
According to Microsoft about NT command shell:
" all reserved shell characters not in double quotes must be escaped. These characters have special meaning to the Windows NT command shell. The reserved shell characters are:
& | ( ) < > ^
To pass reserved shell characters as part of an argument for a command, either the entire argument must be enclosed in double quotes, or the reserved character must be escaped. Prefix a reserved character with a carat (^) character to escape it."

In the command-line that I tried it likely ignored the "^" in the regular expression considering it just an escape character of the following character. This is why it always matched no matter where I put that "^".
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 39269667
did you try adding '^^' instead of '^', should work if I read this
0
 

Author Comment

by:lucavilla
ID: 39269717
yes and it worked but it was becoming too difficult to consider the various special characters in a XPATH to escape them automatically.
Added to the possibility to reach the command-line length limit, I preferred to avoid the problem :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now