Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xpath tests #8

Open
amitmurthy opened this issue Jun 13, 2013 · 8 comments
Open

xpath tests #8

amitmurthy opened this issue Jun 13, 2013 · 8 comments
Assignees

Comments

@amitmurthy
Copy link
Collaborator

add tests for xpath, possibly based on http://msdn.microsoft.com/en-us/library/ms256086.aspx

@amitmurthy
Copy link
Collaborator Author

cc: @vtjnash

Some not-so-trivial xpath queries are failing. Will be good to add some standard tests for the same.

@ghost ghost assigned vtjnash Jun 13, 2013
@vtjnash
Copy link
Collaborator

vtjnash commented Jun 13, 2013

Sounds good, will do.

Can you give some examples of xpath queries that are failing for you? There is a class of unimplemented functionality (e.g. parenthesized expressions, many functions, namespaces, returning objects of types other than nodes), but there is also likely still some legit bugs.

@amitmurthy
Copy link
Collaborator Author

From the above xml

julia> pd["@specialty"]
ERROR: no method convert(Type{ParsedData},ASCIIString)
 in push! at array.jl:663
 in xpath at /home/amitm/.julia/LibExpat/src/xpath.jl:798
 in xpath at /home/amitm/.julia/LibExpat/src/xpath.jl:516
 in getindex at /home/amitm/.julia/LibExpat/src/xpath.jl:898

julia> pd["/@specialty"]
0-element ParsedData Array

julia> pd["//@specialty"]
ERROR: no method convert(Type{ParsedData},ASCIIString)
 in push! at array.jl:663
 in xpath at /home/amitm/.julia/LibExpat/src/xpath.jl:798
 in xpath_descendant at /home/amitm/.julia/LibExpat/src/xpath.jl:891
 in xpath at /home/amitm/.julia/LibExpat/src/xpath.jl:847
 in xpath at /home/amitm/.julia/LibExpat/src/xpath.jl:818
 in xpath at /home/amitm/.julia/LibExpat/src/xpath.jl:516
 in getindex at /home/amitm/.julia/LibExpat/src/xpath.jl:898

julia> pd["/bookstore@specialty"]
0-element ParsedData Array

julia> pd["/bookstore/@specialty"]
ERROR: no method convert(Type{ParsedData},ASCIIString)
 in push! at array.jl:663
 in xpath at /home/amitm/.julia/LibExpat/src/xpath.jl:798
 in xpath at /home/amitm/.julia/LibExpat/src/xpath.jl:806
 in xpath at /home/amitm/.julia/LibExpat/src/xpath.jl:840
 in xpath at /home/amitm/.julia/LibExpat/src/xpath.jl:818
 in xpath at /home/amitm/.julia/LibExpat/src/xpath.jl:516
 in getindex at /home/amitm/.julia/LibExpat/src/xpath.jl:898

The below returns 2 objects, should return only one:

julia> pd["/bookstore/book[1]/author/award"]
2-element ParsedData Array:
 <award>Trenton Literary Review Honorable Mention</award>
 <award>Pulitzer</award> 

cannot get the text anyways:

julia> pd["/bookstore/book[1]/author/award/text()"]
0-element ParsedData Array

julia> 

I have not done extensive testing, was just thinking of using this interface and ran into problems.

@vtjnash
Copy link
Collaborator

vtjnash commented Jun 13, 2013

Some of these are intentionally not supported currently (retrieving attributes via pd["@specialty"] or text text()), so there would only be one possible return type
These ones show correct behavior (pd["/bookstore@specialty"] pd["/@specialty"])

This one seems wrong: pd["/bookstore/book[1]/author/award"]

@amitmurthy
Copy link
Collaborator Author

(pd["/bookstore@specialty"] pd["/@specialty"]) are returning an empty array.

@amitmurthy
Copy link
Collaborator Author

How does one get the text using xpath then? pd["/bookstore/magazine/price#string"] does not work either.

@amitmurthy
Copy link
Collaborator Author

It will also be good to list the xpath subset supported more explicitly in the README.

@vtjnash
Copy link
Collaborator

vtjnash commented Jun 13, 2013

This one pd["/bookstore/book[1]/author/award"] succeeds for me:

julia> pd["/bookstore/book[1]/author/award"]
1-element ParsedData Array:
 <award>Trenton Literary Review Honorable Mention</award>

julia> pd["/bookstore/book[3]/author/award"]
1-element ParsedData Array:
 <award>Pulitzer</award>

I'll add an API to support the other node types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants