Skip to content

Inverse to XPathParser::parse? #95

Description

@pulver

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions