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

Activity #2A #5

Open
jbericat opened this issue Oct 27, 2020 · 8 comments
Open

Activity #2A #5

jbericat opened this issue Oct 27, 2020 · 8 comments
Labels
Follow-Up & Resources Activity follow-up & related resources discussion thread

Comments

@jbericat
Copy link
Member

Here we could share resources related with this activity (bibliography, links, etc), as well as discuss any problem or issue we might face while performing it (English is not mandatory).

@jbericat jbericat added the Follow-Up & Resources Activity follow-up & related resources discussion thread label Oct 27, 2020
@cdelbg
Copy link
Contributor

cdelbg commented Oct 27, 2020

Here we have two websites to test the xPath commands in case we don't want to use any software on our computers:

https://www.freeformatter.com/xpath-tester.html
https://codebeautify.org/Xpath-Tester

@cdelbg
Copy link
Contributor

cdelbg commented Oct 29, 2020

xpath cheatsheet in two different versions

xpath-cookbook.pdf
xpath-cookbook.pdf

@jbericat
Copy link
Member Author

jbericat commented Nov 4, 2020

@cdelbg :

I've been playing around with the xpath expression we already have in the "cdelbg-patch1" branch, "activity_2/pregunta2.xml" file, but I get a result I think is wrong. More precisely, if I modify the xpath expression to return the "confirmed_cases" txt instead of the date, as in below:

/response/row/row[not(preceding-sibling::row/confirmed_cases >= confirmed_cases) and not(following-sibling::row/confirmed_cases > confirmed_cases)]/confirmed_cases/text()

I get this result:

<?xml version="1.0" encoding="UTF-8"?>99

Which is not the node with the highest "confirmed_cases" number, as you can see below:

max

I'll keep working on this before proceeding with the 2B activity (I wanted to let you know just in case you didn't notice, so we can discuss it further 👍 )

@cdelbg
Copy link
Contributor

cdelbg commented Nov 4, 2020

Could it be because of the XML version being used?

@jbericat
Copy link
Member Author

jbericat commented Nov 4, 2020

Ok, I think I've found a workaround: In xpath 2.0 there is a "max()" function that does the trick without having to build complex xpath expressions (Just tried myself successfully).

However, I also had to download the newest version of the "baseX" xml processor from here, which seems to be the only one xpath 2.0 compatible. Afterwards, we can run this (way simpler) query:

max(/response/row/row/confirmed_cases)

Here is the proof:

max

*PS: Xpath 2.0 expressions are also allowed to perform this activity (there is a message in the forum that explicitly says so)

@jbericat
Copy link
Member Author

jbericat commented Nov 4, 2020

Here is the final expression that gives what the assessment asks for:

/response/row/row[confirmed_cases = max(/response/row/row/confirmed_cases)]/start_date/text()

Feel free to try it yourself :)

@jbericat
Copy link
Member Author

jbericat commented Nov 5, 2020

I've already documented this activity in the project memory (There is nothing else to do here)

@cdelbg
Copy link
Contributor

cdelbg commented Nov 6, 2020

I've test at xbase (8.6.7 and 9.4.3) as you suggested and https://codebeautify.org/Xpath-Tester unsuccessfully but it's working at https://www.freeformatter.com/xpath-tester.html and Pathology (the one I have installed on my laptop).
Well done!

ps: anyway it's a bit weird as depending on the tool you have different outcomes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Follow-Up & Resources Activity follow-up & related resources discussion thread
Projects
None yet
Development

No branches or pull requests

2 participants