Why does xmlstarlet say there's no 'ends-with' function?

感情迁移 提交于 2019-12-06 08:18:50

xmlstarlet only supports XPath 1.0, which does not offer an ends-with($string, $token) function. You need to use substring, string-length and and string comparison to construct your own using this pattern:

substring($string, string-length($string) - string-length($token) + 1) = $token]

Applied to your query, it should look like this (I "precomputed" the string length):

/x:databaseChangeLog/x:changeSet[x:createView[
  substring(@viewName, string-length(@viewName)) = 'v']
]

Alternatively, you might want to look for a more powerful XPath 2.0/XQuery engine.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!