我想使用变量来表示我的schematron断言,并在我的验证消息中使用它。例如:
<rule context="//Profile/User[@name]">
<assert test="@name = ../business/@owner">User: '----' doesn't exist as a business owner. </assert>
</rule>
'----'代表用户的名字。有没有办法在schematron中使用变量?
答案 0 :(得分:3)
您可以使用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>