这是我的测试组件
我必须读取 XBL 中实例属性的值。我正在做如下。
或者
我必须连接实例名称和 xpath 来读取值,这是我需要帮助的地方。
我可以像我一样读取 xpath,然后将其与上面的变量连接起来
。 avt='{/*/fr:constraint/@xpath}'" />
我将得到一堆我想重复的元素
<代码>
连接字符串来创建 xpath 并在重复中使用它是问题所在。有什么想法吗?
This is my test component
<fr:mycomponent name="test">
<fr:constraint instance="myinstance" xpath="item/@id" />
</fr:mycomponent>
I have to read the value of instance attribute in XBL. I am doing as follows.
<xsl:value-of select="./fr:constraint/@instance" />
or
<xxforms:variable name="instance" select="xxforms:evaluate-avt='{/*/fr:constraint/@instance}'" />
I have to concat the instance name and xpath to read the values which is where I need help.
<xxforms:variable name="instance" select="concat('instance(''', xxforms:evaluate-avt='{/*/fr:constraint/@instance}'", ''')' />
I can read xpath in the same way as I did for instance and then concat it with the above variable.
<xxforms:variable name="xpath" select="xxforms:evaluate-avt='{/*/fr:constraint/@xpath}'" />
<xxforms:variable name="nodeset" select="concat($instance, '/', $xpath)" />
I will get a bunch of elements which I would like to repeat
<xforms:repeat nodeset="$nodeset">
<xforms:output value="." />
<xforms:repeat/>
Concatenating strings to create xpath and using it in repeat is where the problem is. Any ideas?
发布评论
评论(2)
这取决于
/*/fr:constraint/@instance
的内容:xxforms:evaluate-avt()
是去。但是,也许您可以将其设为 XPath 表达式,而不是 AVT,然后您可以编写:
如果它是实例 id,这似乎是基于您的情况例如,那么您可以按如下方式声明 XForms 变量。 AVT 由 XSLT 解释,因此 XForms 看到的是
select="instance('myinstance')"
。It depends on content of
/*/fr:constraint/@instance
:xxforms:evaluate-avt()
is the way to go.However, maybe you could make that an XPath expression, instead of an AVT, and then you could just write:
If it is an instance id, which seems to be the case based on your example, then you'd declare your XForms variable as follows. The AVT is interpreted by XSLT, so what XForms sees is
select="instance('myinstance')"
.事实上 xxforms:evaluate-avt 有效。这是我的应用程序中的缓存问题。这是后续问题。
XSLT
XForms
这是正确的访问方式吗xforms 中的变量?有更好的办法吗?
In fact xxforms:evaluate-avt worked. It was a caching issue in my app. Here is the followup question.
XSLT
<xsl:value-of select="./fr:constraint/@instance" />
XForms
<xxforms:variable name="instance" select="xxforms:evaluate-avt='{/*/fr:constraint/@instance}'" />
Is this the right way to access the variable in xforms? Is there a better way?