匹配条件下的Xpath

时间:2017-06-30 13:37:15

标签: regex xslt xpath match

给出XML文档:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mappings>
      <mapping match="/path/\d{4}/\d{2}/\d{2}/first/.*" value="value1" />
      <mapping match="/path/\d{4}/\d{2}/\d{2}/second/.*" value="value2" />
      <mapping match="/path/\d{4}/\d{2}/\d{2}/third/.*" value="value3" />
</mappings>

和路径/path/2017/06/30/first/object.ext作为输入,我正在寻找一种方法来选择mapping属性与给定路径匹配的特定match节点。

我试过了:

//mappings/mapping[matches($path,./@match)]/@value

但它似乎不起作用。建议?

0 个答案:

没有答案