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

Inverse to XPathParser::parse? #95

Closed
pulver opened this issue May 24, 2023 · 2 comments
Closed

Inverse to XPathParser::parse? #95

pulver opened this issue May 24, 2023 · 2 comments

Comments

@pulver
Copy link
Contributor

pulver commented May 24, 2023

The following REXML script

require 'rexml'

parsed = REXML::Parsers::XPathParser.new.parse('/a[b/text()=concat("c","d")]')
puts "#{parsed}"
puts ""
appreviated = REXML::Parsers::XPathParser.new.abbreviate parsed
puts "#{appreviated}"

outputs

[:document, :child, :qname, "", "a", :predicate, [:eq, [:child, :qname, "", "b", :child, :text], [:function, "concat", [[:literal, "c"], [:literal, "d"]]]]]

/a[ b/text() = concat( UNKNOWN([:literal, "c"])/UNKNOWN([:literal, "d"]) ) ]

I know about the warning against using REXML::Parsers::XPathParser but is there any way to get back the xpath string /a[b/text()=concat("c","d")] from its parsed/tokenized version?

I'm working on an application that requires heavy manipulation of xpaths (version 1.0) and am looking for a library to help with this.

REXML version: 3.2.5

@kou kou closed this as completed in 54b7109 May 25, 2023
@kou
Copy link
Member

kou commented May 25, 2023

Could you try master?

@pulver
Copy link
Contributor Author

pulver commented May 25, 2023

That fixes that particular issue, thanks. There is a related issue with quoting literals that is fixed by #96

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

No branches or pull requests

2 participants