title: Orbeon forms, dropdown items set from selected checkbox values
body: <p>Im working with the FormBuilder: Orbeon Forms 2016.2.1.201609272302 PE.</p>
  
  <p>Ive been trying to create a dynamically populating dropdown list from the checked (selected) values in a checkbox control field (i.e., every checked value is on option in the dropdown)</p>
  
  <p>Heres the example i've been working with, </p>
  
  <pre><code>&lt;xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:xxf="http://orbeon.org/oxf/xml/xforms" xmlns:exf="http://www.exforms.org/exf/1-0" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:saxon="http://saxon.sf.net/" xmlns:sql="http://orbeon.org/oxf/xml/sql" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fb="http://orbeon.org/oxf/xml/form-builder"&gt;
  &lt;xh:head&gt;
      &lt;xh:title&gt;gtest&lt;/xh:title&gt;
      &lt;xf:model id="fr-form-model" xxf:expose-xpath-types="true"&gt;
          &lt;!-- Main instance --&gt;
          &lt;xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all" xxf:index="id"&gt;
              &lt;form&gt;
                  &lt;section-1&gt;
                      &lt;control-2&gt;t5 t4&lt;/control-2&gt;
                      &lt;control-4/&gt;
                      &lt;control-3/&gt;
                  &lt;/section-1&gt;
              &lt;/form&gt;
          &lt;/xf:instance&gt;
          &lt;!-- Bindings --&gt;
          &lt;xf:bind id="fr-form-binds" ref="instance('fr-form-instance')"&gt;
              &lt;xf:bind id="section-1-bind" name="section-1" ref="section-1"&gt;
                  &lt;xf:bind id="control-2-bind" ref="control-2" name="control-2" /&gt;
                  &lt;xf:bind id="control-3-bind" ref="control-3" name="control-3" /&gt;
                  &lt;xf:bind id="control-4-bind" ref="control-4" name="control-4" calculate="$control-2" /&gt;
              &lt;/xf:bind&gt;
          &lt;/xf:bind&gt;
          &lt;!-- Metadata --&gt;
          &lt;xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all"&gt;
              &lt;metadata&gt;
                  &lt;application-name&gt;test&lt;/application-name&gt;
                  &lt;form-name&gt;test&lt;/form-name&gt;
                  &lt;title xml:lang="en"&gt;gtest&lt;/title&gt;
                  &lt;description xml:lang="en"&gt;testing dynamic dropdown based on checklist values.&lt;/description&gt;
              &lt;/metadata&gt;
          &lt;/xf:instance&gt;
          &lt;!-- Attachments --&gt;
          &lt;xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all"&gt;
              &lt;attachments&gt;
                  &lt;css mediatype="text/css" filename="" size="" /&gt;
                  &lt;pdf mediatype="application/pdf" filename="" size="" /&gt;
              &lt;/attachments&gt;
          &lt;/xf:instance&gt;
          &lt;!-- All form resources --&gt;
          &lt;xf:instance xxf:readonly="true" id="fr-form-resources" xxf:exclude-result-prefixes="#all"&gt;
              &lt;resources&gt;
                  &lt;resource xml:lang="en"&gt;
                      &lt;control-2&gt;
                          &lt;label&gt;checklist&lt;/label&gt;
                          &lt;hint/&gt;&lt;item&gt;&lt;label&gt;t1&lt;/label&gt;&lt;hint/&gt;&lt;value&gt;t1&lt;/value&gt;
                          &lt;/item&gt;&lt;item&gt;&lt;label&gt;t2&lt;/label&gt;&lt;hint/&gt;&lt;value&gt;t2&lt;/value&gt;
                          &lt;/item&gt;&lt;item&gt;&lt;label&gt;t3&lt;/label&gt;&lt;hint/&gt;&lt;value&gt;t3&lt;/value&gt;
                          &lt;/item&gt;&lt;item&gt;&lt;label&gt;t4&lt;/label&gt;&lt;hint/&gt;&lt;value&gt;t4&lt;/value&gt;
                          &lt;/item&gt;&lt;item&gt;&lt;label&gt;t5&lt;/label&gt;&lt;hint/&gt;&lt;value&gt;t5&lt;/value&gt;
                          &lt;/item&gt;&lt;item&gt;&lt;label&gt;t6&lt;/label&gt;&lt;hint/&gt;&lt;value&gt;t6&lt;/value&gt;
                          &lt;/item&gt;&lt;item&gt;&lt;label&gt;t7&lt;/label&gt;&lt;hint/&gt;&lt;value&gt;t7&lt;/value&gt;
                          &lt;/item&gt;
                      &lt;/control-2&gt;
                      &lt;control-4&gt;
                          &lt;label&gt;selected values&lt;/label&gt;
                          &lt;hint/&gt;
                      &lt;/control-4&gt;
                      &lt;control-3&gt;
                          &lt;label&gt;dynamic dropdown list&lt;/label&gt;
                          &lt;hint/&gt;
                          &lt;xf:itemset ref="$control-2"&gt;
                              &lt;xf:label ref="." /&gt;
                              &lt;xf:value ref="." /&gt;
                          &lt;/xf:itemset&gt;
                      &lt;/control-3&gt;
                      &lt;section-1&gt;
                          &lt;label&gt;Dropdown from checklist&lt;/label&gt;
                      &lt;/section-1&gt;
                  &lt;/resource&gt;
              &lt;/resources&gt;
          &lt;/xf:instance&gt;
          &lt;!-- Utility instances for services --&gt;
          &lt;xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all"&gt;
              &lt;request/&gt;
          &lt;/xf:instance&gt;
          &lt;xf:instance id="fr-service-response-instance" xxf:exclude-result-prefixes="#all"&gt;
              &lt;response/&gt;
          &lt;/xf:instance&gt;
      &lt;/xf:model&gt;
  &lt;/xh:head&gt;
  &lt;xh:body&gt;
      &lt;fr:view&gt;
          &lt;fr:body xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:oxf="http://www.orbeon.com/oxf/processors"&gt;
              &lt;fr:section id="section-1-control" bind="section-1-bind"&gt;
                  &lt;xf:label ref="$form-resources/section-1/label" /&gt;
                  &lt;fr:grid&gt;
                      &lt;xh:tr&gt;
                          &lt;xh:td&gt;
                              &lt;xf:select id="control-2-control" appearance="full" bind="control-2-bind"&gt;
                                  &lt;xf:label ref="$form-resources/control-2/label" /&gt;
                                  &lt;xf:hint ref="$form-resources/control-2/hint" /&gt;
                                  &lt;xf:alert ref="$fr-resources/detail/labels/alert" /&gt;
                                  &lt;xf:itemset ref="$form-resources/control-2/item"&gt;
                                      &lt;xf:label ref="label" /&gt;
                                      &lt;xf:value ref="value" /&gt;
                                      &lt;xf:hint ref="hint" /&gt;
                                  &lt;/xf:itemset&gt;
                              &lt;/xf:select&gt;
                          &lt;/xh:td&gt;
                      &lt;/xh:tr&gt;
                      &lt;xh:tr&gt;
                          &lt;xh:td&gt;
                              &lt;xf:output id="control-4-control" bind="control-4-bind"&gt;
                                  &lt;xf:label ref="$form-resources/control-4/label" /&gt;
                                  &lt;xf:hint ref="$form-resources/control-4/hint" /&gt;
                                  &lt;xf:alert ref="$fr-resources/detail/labels/alert" /&gt;
                              &lt;/xf:output&gt;
                          &lt;/xh:td&gt;
                      &lt;/xh:tr&gt;
                      &lt;xh:tr&gt;
                          &lt;xh:td&gt;
                              &lt;fr:dropdown-select1 xmlns:xxbl="http://orbeon.org/oxf/xml/xbl" id="control-3-control" bind="control-3-bind"&gt;
                                  &lt;xf:label ref="$form-resources/control-3/label" /&gt;
                                  &lt;xf:hint ref="$form-resources/control-3/hint" /&gt;
                                  &lt;xf:alert ref="$fr-resources/detail/labels/alert" /&gt;
                                  &lt;xf:itemset ref="$form-resources/control-2/item[label=('t1', 't2', 't4')]"&gt;
                                      &lt;xf:label ref="label" /&gt;
                                      &lt;xf:value ref="value" /&gt;
                                      &lt;xf:hint ref="hint" /&gt;
                                  &lt;/xf:itemset&gt;
                              &lt;/fr:dropdown-select1&gt;
                          &lt;/xh:td&gt;
                      &lt;/xh:tr&gt;
                  &lt;/fr:grid&gt;
              &lt;/fr:section&gt;
          &lt;/fr:body&gt;
      &lt;/fr:view&gt;
  &lt;/xh:body&gt;
  &lt;/xh:html&gt;
  </code></pre>
  
  <p>If im able to convert the checklist values into a comma separated list using XPath or some Orbeon Function, I'll have a solution:</p>
  
  <pre><code>&lt;xf:itemset ref="$form-resources/control-2/item[label=(&lt;list of values&gt;)]"&gt;
    &lt;xf:label ref="label" /&gt;
    &lt;xf:value ref="value" /&gt;
    &lt;xf:hint ref="hint" /&gt;
  &lt;/xf:itemset&gt;
  </code></pre>
  
  <p>where <code>&lt;list of values&gt;</code> looks like <code>'t1', 't2', 't3'</code>.</p>