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" />
<xxforms:variable name="instance" select="xxforms:evaluate-avt='{/*/fr:constrain开发者_JS百科t/@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?
It depends on content of /*/fr:constraint/@instance
:
- If it is an AVT, then yes, using
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:
<xxforms:variable name="instance" select="{/*/fr:constraint/@instance}"/>
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:variable name="instance" select="instnce('{/*/fr:constraint/@instance}')"/>
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?
精彩评论