当用户尝试使用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 (或其声明不在作用域中)
发布于 2019-06-10 00:55:09
目前还没有支持在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。
https://stackoverflow.com/questions/56485065
复制相似问题