module XPath
Helpers for working with XPath.
Definitions
def self.escape(value)
Escape a value for use in XPath.
XPath 1.0 does not provide any standard mechanism for escaping quotes, so we have to do it ourselves using concat
.
Signature
-
parameter
value
String | Numeric
The value to escape.
Implementation
def self.escape(value)
case value
when String
if value.include?("'")
"concat('#{value.split("'").join("', \"'\", '")}')"
else
"'#{value}'"
end
else
value.to_s
end
end