我要疯了..。
test使用广泛的匹配失败-任何类似于'^.+$'的正则表达式(如样例文件中所示),但是可以使用特定的'^C.+$'。
我也尝试过test="string-length(.) > 0",但失败了。
请帮帮忙。
这个XML文件:
<article>
<back><ack>
<title>Acknowledgements</title>
<p>The authors would like to thank <funding-source rid="sp1">CNPq</funding-source> (Process numbers <award-id rid="sp1">303287/2013-6</award-id> and <award-id rid="sp1">303559/2012-8</award-id>), <funding-source rid="sp2">FAPESP</funding-source> (Process number <award-id rid="sp2">2012/12207-6</award-id>) and <funding-source rid="sp3">CAPES</funding-source> (Process number <award-id rid="sp3">12357-13-8</award-id>) for the financial support.</p>
</ack></back></article>--这是失败的模式文件:
<schema xmlns="http://purl.oclc.org/dsdl/schematron"
queryBinding="exslt"
xml:lang="en">
<ns uri="http://www.w3.org/1999/xlink" prefix="xlink"/>
<ns uri="http://exslt.org/regular-expressions" prefix="regexp"/>
<pattern id="funding_info">
<title>Make sure funding-source does not happen inside p</title>
<assert test="regexp:test(current(), '^.+$')">
EC-CHECK: Nao deve haver 'funding-source' nem 'award-id' dentro de 'p'
</assert>
</rule>
</pattern>
</schema>--这是工作的模式文件:
<schema xmlns="http://purl.oclc.org/dsdl/schematron"
queryBinding="exslt"
xml:lang="en">
<ns uri="http://www.w3.org/1999/xlink" prefix="xlink"/>
<ns uri="http://exslt.org/regular-expressions" prefix="regexp"/>
<pattern id="funding_info">
<title>Make sure funding-source does not happen inside p</title>
<assert test="regexp:test(current(), '^C.+$')">
EC-CHECK: Nao deve haver 'funding-source' nem 'award-id' dentro de 'p'
</assert>
</rule>
</pattern>
</schema>发布于 2016-02-10 11:37:34
似乎XSL中的反斜杠可以用来定义转义序列。当您需要定义regex速记字符类时,您需要在特定字符前面加上一个文字反斜杠,因此,您需要使用一个双反斜杠:
^[\\s\\S]+$此模式将匹配:
^ -字符串的开始[\\s\\S]+ -一个或多个字符是空白或非空白(因此,这匹配任何字符)$ -字符串的末端。这也意味着regex的味道不是JavaScript,尽管本参考声称EXSLT使用JS风味。
https://stackoverflow.com/questions/35232527
复制相似问题