2010-11-18 17 views
1

これは私のテストコンポーネントですXBLコンポーネントの子要素を読み、xpathを構築する

<xxforms:variable name="instance" select="xxforms:evaluate-avt='{/*/fr:constraint/@instance}'" /> <fr:constraint instance="myinstance" xpath="item/@id" />
</fr:mycomponent>

私はXBLのインスタンス属性の値を読み取る必要があります。私は次のようにしています。

<xsl:value-of select="./fr:constraint/@instance" />
または <xxforms:variable name="instance" select="xxforms:evaluate-avt='{/*/fr:constraint/@instance}'" />

私は助けが必要な値を読み取るために、インスタンス名とxpathを連結する必要があります。 <xxforms:variable name="instance" select="concat('instance(''', xxforms:evaluate-avt='{/*/fr:constraint/@instance}'", ''')' />

私は例と同じ方法でxpathを読み込み、上記の変数と連結することができます。

<xxforms:variable name="xpath" select="xxforms:evaluate-avt='{/*/fr:constraint/@xpath}'" />
<xxforms:variable name="nodeset" select="concat($instance, '/', $xpath)" />

<xforms:repeat nodeset="$nodeset">

<xforms:repeat/>

xpathを作成して繰り返しで使用するために文字列を連結する問題がどこにあるのか。何か案は?

+0

私はxxformsを試してみました:($のノードセット)を評価し、xxforms:あまりにも(CONCAT($のノードセット、 '/'、 '$のXPathを'))を評価。 – BinnyG

答えて

0

これは/*/fr:constraint/@instanceの内容によって異なります。

  1. それはAVTある場合は、[はい、xxforms:evaluate-avt()を使用して移動するための方法です。
  2. しかし、多分あなたの代わりにAVTの、XPath式ということ作ることができ、その後、あなただけ書くことができます:

    <xxforms:variable name="instance" 
            select="{/*/fr:constraint/@instance}"/> 
    
  3. をそれがベースのケースであるように思わインスタンスIDの場合、あなたの例では、XForms変数を次のように宣言します。 AVTはXSLTによって解釈されるので、XFormsが見るものはselect="instance('myinstance')"です。

    <xxforms:variable name="instance" 
            select="instnce('{/*/fr:constraint/@instance}')"/> 
    
0

実際にはxxforms:evaluate-avt worked。それは私のアプリのキャッシングの問題でした。ここでは、フォローアップの質問です。

XSLT
<xsl:value-of select="./fr:constraint/@instance" />

のXForms
<xxforms:variable name="instance" select="xxforms:evaluate-avt='{/*/fr:constraint/@instance}'" />

これはXFormsの中の変数にアクセスするための正しい方法ですか?より良い方法がありますか?

関連する問題