如何从sqf:user-entry获取值?

时间:2019-06-06 21:04:29

标签: schematron schematron-quickfix

当用户尝试使用schematron规则应用快速修复并将值用作替换操作中的变量时,我想从用户获取两个整数。但我收到错误消息,说“变量尚未声明”

我有这个schematron规则,该规则在一个步骤中找到第一个空选择元素,并提示用户应用快速修复。当用户应用快速修复时,将出现一个对话框,提示用户提供两个整数。用户输入将用于计算步骤元素的范围。

Schematron规则

<sch:rule context="choice[1][not(normalize-space())]">
            <sch:assert test="choice[1][not(normalize-space())]" sqf:fix='editchoice'>great
            </sch:assert>

</sch:rule>

修复

 <sqf:fix id="editchoice">
          <sqf:description>
              <sqf:title>Enter the last step number</sqf:title>
          </sqf:description>

          <sqf:user-entry name="step1" type="xs:integer" >
              <sqf:description>
                  <sqf:title>Enter the first step to be converted to choice</sqf:title>
              </sqf:description>
          </sqf:user-entry>

          <sqf:user-entry name="laststep" type="xs:integer">
              <sqf:description>
                  <sqf:title>Enter the last step to be converted</sqf:title>
              </sqf:description>

          </sqf:user-entry>

          <sqf:replace match="./ancestor::steps/step[position()>$step1 and not(position()>=$laststep)]" target='choice' node-type='keep'></sqf:replace>

      </sqf:fix>

预期结果

$ step1和$ laststep应该替换为用户输入值。

实际结果

变量step1尚未声明(或其声明不在范围内)

1 个答案:

答案 0 :(得分:0)

当前没有实现支持match属性中用户条目的使用(我正在努力...)。

与此同时,您必须这样做:

<sqf:replace match="./ancestor::steps/step">
    <sch:let name="pos" value="count(preceding-sibling::step) + 1"/>
    <xsl:choose>
        <xsl:when test="$pos > number($step1) and not($pos >= number($laststep))">
            <choice/>
        </xsl:when>
        <xsl:otherwise>
            <sqf:copy-of select="."/>
        </xsl:otherwise>
    </xsl:choose>
</sqf:replace>

注意:您需要使用number(),因为Oxygen nativ实施尚不支持type用户输入。

相关问题