首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从sqf:user-entry获取值?

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

Stack Overflow用户
提问于 2019-06-07 05:04:29
回答 1查看 34关注 0票数 0

当用户尝试使用schematron规则应用快速修复并在替换操作中使用这些值作为变量时,我希望从用户那里获得两个整数。但是我得到的错误是“变量没有被声明”

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

schematron规则

代码语言:javascript
复制
<sch:rule context="choice[1][not(normalize-space())]">
            <sch:assert test="choice[1][not(normalize-space())]" sqf:fix='editchoice'>great
            </sch:assert>
     
</sch:rule>

修复方法

代码语言:javascript
复制
 <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 (或其声明不在作用域中)

EN

回答 1

Stack Overflow用户

发布于 2019-06-10 00:55:09

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

同时,你必须这样做:

代码语言:javascript
复制
<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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56485065

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档