【问题标题】:How to get the value from sqf:user-entry?如何从 sqf:user-entry 中获取值?
【发布时间】:2019-06-06 21:04:29
【问题描述】:

当用户尝试使用 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没有被声明(或者它的声明不在范围内)

【问题讨论】:

    标签: schematron schematron-quickfix


    【解决方案1】:

    目前没有支持在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

    【讨论】:

      猜你喜欢
      • 2023-01-30
      • 1970-01-01
      • 2020-11-07
      • 2015-05-10
      • 1970-01-01
      • 1970-01-01
      • 2018-06-18
      • 1970-01-01
      • 2021-07-09
      相关资源
      最近更新 更多