给出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
但它似乎不起作用。建议?