我想使用一个变量来表示我的 schematron 断言并在我的验证消息中使用它。例如:
<rule context="//Profile/User[@name]">
<assert test="@name = ../business/@owner">User: '----' doesn't exist as a business owner. </assert>
</rule>
'----' 是用户的名称。有没有办法在 schematron 中使用变量?
最佳答案
您可以使用 value-of
来检索变量或 XPath 的值:
<rule context="//Profile/User[@name]">
<assert test="@name = ../business/@owner">
User: <value-of select="@name"/> doesn't exist as a business owner.
</assert>
</rule>
如果你想引入一个变量,使用let
:
<rule context="//Profile/User[@name]">
<let name="userName" value="@name"/>
<assert test="@name = ../business/@owner">
User: <value-of select="$userName"/> doesn't exist as a business owner.
</assert>
</rule>
关于xml - 有没有办法在 schematron 中传递变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41948482/