1

XForms のユーザー入力から 2 つの異なるノードに 2 つの値を設定したいと考えています。可能であれば、これがどのように行われるのか興味があります。

たとえば、次のデータ モデルがあるとします。

<xf:instance id="criteria_data" xmlns="">
    <criteria>
        <set>
           <root></root>
           <criterion></criterion>
        </set>
    </criteria>
</xf:instance>

<xf:instance id="choices" xmlns="">
    <choices>
        <root label="The Choices">/AAA</root>
        <choice label="BBB">/@BBB</choice>
    </choices>
</xf:instance>

<xf:instance id="choices" xmlns="">
    <choices>
        <root>/AAA</root>
        <choice label="BBB">/@BBB</choice>
        <choice label="CCC">/@CCC</choice>
    <choices>
</xf:instance>

<xf:bind id="data_criterion" nodeset="instance('criteria_data')/criteria/set/criterion"/>         
<xf:bind id="data_root" nodeset="instance('criteria_data')/criteria/set/root"/>
<xf:bind id="choices_root" nodeset="instance('choices')/root"/>
<xf:bind id="choices" nodeset="instance('choices')/choice"/>

そして私のUIコードは次のようになります:

<xf:select bind="data_criterion" appearance="full">
    <xf:label>Your choices:</xf:label>    
    <xf:itemset bind="choices">
       <xf:label ref="@label"></xf:label>
       <xf:value ref="."></xf:value>
    </xf:itemset>
</xf:select>    

しかし、私は基本的に次のようにしたいと考えています (ただし、これは無効であり、xml はまったく生成されません)。

<xf:select appearance="full">
    <xf:label>Your choices:</xf:label>    
    <xf:itemset bind="choices">
        <xf:label ref="@label"></xf:label>
        <xf:value bind="data_criterion" ref="."></xf:value>
        <xf:value bind="data_root" ref="instance('choices')/root"></xf:value>
    </xf:itemset>
</xf:select>    

達成したいXML出力(ユーザーが「BBB」をチェックした場合):

<criteria>
    <set>
       <root>/AAA</root>
       <criterion>/@BBB</criterion>
    </set>
</criteria>

1 つのチェックボックスの選択に対してこれら 2 つのノードを設定するにはどうすればよいですか?

すべてが理にかなっていることを願っています...

ありがとう!:)

4

2 に答える 2

0

次の計算を使用することもできます。

<xf:bind nodeset="instance('criteria_data')/criteria/set/root" calculate="instance
('choices')/choice[. = instance('criteria_data')/criteria/set/criterion]/../root">
于 2010-06-11T08:40:05.627 に答える
0

イベント「xforms-select」で実行される「xf:setvalue」などの特定のアクションを宣言する必要があります。

-アラン

于 2010-06-11T04:36:36.303 に答える