On Tue, 18 Jul 2017 10:58:58 +0200, C. M. Sperberg-McQueen
<cms...@blackmesatech.com> wrote:
The problem here is so simple it’s slightly embarrassing: the ‘ref’
attribute on xf:select sets the context item, so the relative expression
in the xf:itemset/@nodeset attribute cannot (as written) succeed: no
attribute every has element children. If one makes it absolute
(lead with instance(‘name’)/… or with ../../), the drop down menu
ceases to be empty.
Just as a reminder for everyone, if you have a @ref on a control (which as
Michael points out resets the context), and you have a nested expression
that you want to be relative to the same thing the ref was relative to
before resetting the context, there is a solution: the context() function.
This function gives you the context used for the ref, while "." gives you
the context produced by the ref.
Example:
<select ref="p[@id='select']/@items">
<itemset ref="list/item">
the itemset would try to reference "p[@id='select']/@items/list/item"
(obviously empty).
<select ref="p[@id='select']/@items">
<itemset ref="context()/list/item">
would be evaluated in the same contact as the ref on <select>.
You can see another example of context() being used in this example:
http://homepages.cwi.nl/~steven/forms/examples/data-driven/
- Second, when I try to use xf:output in the xf:label element,
I get an error; ditto when I try to use a constant but remove the @ref
binding attribute. Are both the value and the label of an itemset
required to use @ref?
For this I have currently found no simple solution.
This may help:
<repeat ref="*">
<input ref=".[count(*)=0]"><label><output value="concat(name(.), ':
')"/></label></input>
<output value="if(count(*)=0, '', concat(name(.), ': '))"/>
<repeat ref="@*" class="inline">
<input ref="."><label><output value="concat('@', name(.),
'=')"/></label></input>
</repeat>
**NEST HERE**
</repeat>
At the point **NEST HERE** you just copy and paste the whole repeat again;
do this as many times as needed to match the maximum depth of elements in
the instance you have.
In your case you need outputs not inputs, so just replace all <input>s
with <output>s.
You can see it working at
http://homepages.cwi.nl/~steven/forms/examples/data-driven/edit.xml
It takes any random XML instance, and allows you to edit it (up to a
maximum depth).
Hope this helps.
Steven
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Xsltforms-support mailing list
Xsltforms-support@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xsltforms-support