Is there a way to pass a variable to schematron?

I want to use a variable to represent my schema statement and use it in my validation message. For instance:

        <rule context="//Profile/User[@name]">
            <assert test="@name = ../business/@owner">User: '----' doesn't exist as a business owner. </assert>
        </rule>

"----" regardless of the username. Is there a way to use variables in schematron?

+4
source share
1 answer

You can use value-ofto get the value of a variable or 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>

If you want to enter a variable, use 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>
+3
source

Source: https://habr.com/ru/post/1668337/


All Articles