引用属性中保存的数据时,XSLTForms 计算不起作用

XSLTForms calculation not working when referencing data held in attributes

如果以下问题措辞不当,我深表歉意,我对 XML 中所有正确术语的经验有限。

所以我最近一直在使用 XSLTForms 作为一种快速生成 xml 测试数据表示以进入我的工作场所 LIMS 系统的方法。但是,由于必须形成 xml 的方式,我似乎遇到了 XSLTForms 或我正在使用的 XPath 语法的障碍。

简化我的 xml 格式以制作一个小的工作示例 xhtml 文件如下:

<?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ev="http://www.w3.org/2001/xml-events">
<head>
    <title>Example Test</title>
    <xf:model>
        <xf:instance>
            <root xmlns="">
                <child name="one" value=""></child>
                <child name="two" value=""></child>
                <child name="three" value=""></child>
            </root>
        </xf:instance>
        <xf:bind id="ChildOne" ref="child[@name='one']" type="xs:decimal" />
        <xf:bind id="ChildTwo" ref="child[@name='two']" type="xs:decimal" />
        <xf:bind id="ChildThree" ref="child[@name='three']" calculate="../child[@name='one'] - ../child[@name='two']"
            type="xs:decimal" />
    </xf:model>
</head>
<body>
    <xf:input bind="ChildOne">
        <xf:label>Node One:</xf:label>
    </xf:input>
    <xf:input bind="ChildTwo">
        <xf:label>Node Two:</xf:label>
    </xf:input>
    <xf:output ref="child[@name='three']">
        <xf:label>Node Three Calculation:</xf:label>
    </xf:output>
</body>
</html>

这工作正常,输入存储在相关节点中,最终绑定标记中的计算属性计算出存储在 ChildThree 中的 ChildOne 和 ChildTwo 的差异。最后,输出标签显示ChildThree节点的值。

当 Xpath 表达式中的值存储在打开和关闭子节点之间时,bind 中的计算属性可以正常工作,例如:

<child name="ChildOne" value="">10</child>

但正如我在开头提到的,xhtml 代码是一个工作示例,当我开始调整代码以匹配 LIMS 系统的 XML 结构时,事情就中断了。

如果我更改绑定以使用@value 引用子节点的值属性:

    <xf:bind id="ChildOne" ref="child[@name='one']/@value" type="xs:decimal" />
    <xf:bind id="ChildTwo" ref="child[@name='two']/@value" type="xs:decimal" />
    <xf:bind id="ChildThree" ref="child[@name='three']/@value" calculate="../child[@name='one']/@value - ../child[@name='two']/@value"
        type="xs:decimal" />

同时更新输出 ref 属性如下:

<xf:output ref="child[@name='three']/@value">
    <xf:label>Node Three Calculation:</xf:label>
</xf:output>

对 value 属性的赋值似乎适用于绑定到输入标签的 ChildOne 和 ChildTwo。这已从我的工作代码 xml 输出中得到证实,但计算无法正常工作,因为值属性中仅存储了零。

我是否在计算属性 XPath 表达式中遗漏了什么?

calculate="../child[@name='one']/@value - ../child[@name='two']/@value"

任何帮助将不胜感激,提前致谢。

在 bind/@ref 中添加“/@value”时,必须相应地修改计算 MIP:calculate="../../child[@name='one']/@value - ../../child[@name='two']/@value