代码之家  ›  专栏  ›  技术社区  ›  wsalesky

XForms:根据xf:repeat中的当前元素名称从实例中获取值

  •  -1
  • wsalesky  · 技术社区  · 4 年前

    在下面的XForm中,我想将xf:labels(以及最终的其他XForm控件或值)链接到“I-elementSchema”实例中的元素。我无法找到正确的XPath将xf:repeat中的当前元素名称链接到模式中匹配的元素标签。我正在使用XSLTForms。有什么想法吗?

    此处为完整的测试代码: https://gist.github.com/wsalesky/30ca5c0d7b6f9fdc2b3a112a1a8594f9

    XForms模型:

    <xf:model>
            <xf:instance id="i-rec">
                <TEI xmlns="http://www.tei-c.org/ns/1.0">
                    <handDesc hands="">
                        <summary/>
                        <handNote xml:id="" scope="" script="" mode="" quality="" medium="">
                            <p about="" style=""/>
                            <persName ref="" role=""/>
                            <p/>
                            <placeName ref=""/>
                        </handNote>
                    </handDesc>
                </TEI>
            </xf:instance>
            <xf:instance id="i-elementSchema">
                <TEI xmlns="http://www.tei-c.org/ns/1.0">
                    <summary name="summary" label="Summary"/>
                    <handNote name="handNote" label="Hand Note"/>
                    <p name="p" label="Paragraph"/>
                    <persName name="persName" label="Person Name"/>
                    <placeName name="placeName" label="Place Name"/>
                </TEI>
            </xf:instance>
        </xf:model>
    

    XForms用户界面:

    <xf:repeat ref="instance('i-rec')//*:handDesc/*" id="handNote">
                <div class="moveInput" draggable="true">
                    <xf:input ref=".">
                        <xf:label>               
                            <xf:output value="instance('i-elementSchema')/descendant-or-self::*[@name = local-name(.)][1]/@label"/> 
                        </xf:label>
                    </xf:input>
                </div>
            </xf:repeat>
    
    0 回复  |  直到 4 年前
        1
  •  0
  •   wsalesky    4 年前

    在Twitter上回答,使用current():

    instance('i-elementSchema')/descendant-or-self::*[local-name() = local-name(current())]/@label