xml - xsl 中“ends-with”语法的替代方案
问题描述
从这个来源引用
ends-with 不适用于 XPATH 1.0,但我需要它的功能才能在我的应用程序上工作。
这是我需要匹配特定确切字符串的代码片段
<xsl:template match="p:Project/p:ItemGroup/p:Reference[starts-with(@Include, 'Common')]/@Include">
在该行中,我尝试将其修改为此以实现所需的输出,根据异常“ends-with syntax is not part of XPATH 1.0”
<xsl:template match="p:Project/p:ItemGroup/p:Reference[starts-with(@Include, 'Common') and ends-with(@Include, 'Common') ]/@Include">
有没有其他方法可以做到这一点?
我需要做到这一点,因为要修改的xml文件中有部分以“Common”开头的字符串,如Common.UI,Common.Windows.Grid,所以在运行时,它也会影响这些行
它应该只改变一个只有“Common”的
解决方案
该公式已在您提供的链接中说明。由于懒得分析,请测试以下内容:
<xsl:template match="p:Project/p:ItemGroup/p:Reference[starts-with(@Include, 'Common') and 'Common' = substring(@Include, string-length() - 5)]/@Include">
推荐阅读
- android - 带有导体控制器的 ViewPager
- python - Subclassing multiprocessing.queue.Queue: attributes set by parent not available to child?
- python-3.x - Seaborn dashed line not dashed in the legend
- amazon-web-services - How to keep AWS APPSync APIs in sync from Dev to Staging to Production?
- css - How do i replace social media links in navbar with icons?
- angular - MatSort breaks MatTable detail row animations
- python - OpenCV:不正确的自我类型(必须是“CascadeClassifier”或其派生词)
- python - id() 是否返回 CPython 中的实际内存地址?
- php - 如何以干净的方式通过测试更新方法的所有必填字段?
- javascript - Chartist url on click with a bar chart - javascript