Skip to content

Instantly share code, notes, and snippets.

@avernet
Created February 13, 2015 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avernet/3821ceb84b026f8bb391 to your computer and use it in GitHub Desktop.
Save avernet/3821ceb84b026f8bb391 to your computer and use it in GitHub Desktop.
Lookup in repeated grid
<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">
<xh:head>
<xh:title>Untitled Form</xh:title>
<xf:model id="fr-form-model" xxf:expose-xpath-types="true">
<!-- Main instance -->
<xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all">
<form>
<additions>
<lookup>
<lookup-iteration>
<k1>1</k1>
<k2>2</k2>
<v1>3</v1>
</lookup-iteration>
<lookup-iteration>
<k1>4</k1>
<k2>5</k2>
<v1>9</v1>
</lookup-iteration>
<lookup-iteration>
<k1>10</k1>
<k2>11</k2>
<v1>21</v1>
</lookup-iteration>
</lookup>
</additions>
<section-7>
<q1>4</q1>
<q2>5</q2>
<a1/>
</section-7>
</form>
</xf:instance>
<!-- Bindings -->
<xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
<xf:bind id="additions-bind" name="additions" ref="additions">
<xf:bind id="lookup-bind" ref="lookup" name="lookup">
<xf:bind id="lookup-iteration-bind" ref="lookup-iteration" name="lookup-iteration">
<xf:bind id="k1-bind" ref="k1" name="k1"/>
<xf:bind id="k2-bind" ref="k2" name="k2"/>
<xf:bind id="v1-bind" ref="v1" name="v1"/>
</xf:bind>
</xf:bind>
</xf:bind>
<xf:bind id="section-7-bind" ref="section-7" name="section-7">
<xf:bind id="q1-bind" ref="q1" name="q1"/>
<xf:bind id="q2-bind" ref="q2" name="q2"/>
<xf:bind id="a1-bind" ref="a1" name="a1"
calculate="/form/additions/lookup/lookup-iteration[k1 = $q1 and k2 = $q2]/v1"/>
</xf:bind>
</xf:bind>
<!-- Metadata -->
<xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
<metadata>
<application-name>a</application-name>
<form-name>a</form-name>
<title xml:lang="en">Untitled Form</title>
<description xml:lang="en"/>
<singleton>false</singleton>
</metadata>
</xf:instance>
<!-- Attachments -->
<xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all">
<attachments>
<css mediatype="text/css" filename="" size=""/>
<pdf mediatype="application/pdf" filename="" size=""/>
</attachments>
</xf:instance>
<!-- All form resources -->
<!-- Don't make readonly by default in case a service modifies the resources -->
<xf:instance id="fr-form-resources" xxf:readonly="false" xxf:exclude-result-prefixes="#all">
<resources>
<resource xml:lang="en">
<q1>
<label>q1</label>
<hint/>
</q1>
<q2>
<label>q2</label>
<hint/>
</q2>
<a1>
<label>a1</label>
<hint/>
</a1>
<k1>
<label>k1</label>
<hint/>
</k1>
<k2>
<label>k2</label>
<hint/>
</k2>
<v1>
<label>v1</label>
<hint/>
</v1>
<additions>
<label>Untitled Section</label>
</additions>
<section-7>
<label/>
<help/>
</section-7>
</resource>
</resources>
</xf:instance>
<!-- Utility instances for services -->
<xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all">
<request/>
</xf:instance>
<xf:instance id="fr-service-response-instance" xxf:exclude-result-prefixes="#all">
<response/>
</xf:instance>
<xf:instance xxf:readonly="true" id="lookup-template">
<lookup-iteration>
<k1/>
<k2/>
<v1/>
</lookup-iteration>
</xf:instance>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<fr:body xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:p="http://www.orbeon.com/oxf/pipeline">
<fr:section id="additions-control" bind="additions-bind">
<xf:label ref="$form-resources/additions/label"/>
<fr:grid id="lookup-control" bind="lookup-bind" repeat="content" min="1"
template="instance('lookup-template')">
<xh:tr>
<xh:td>
<xf:input id="k1-control" bind="k1-bind">
<xf:label ref="$form-resources/k1/label"/>
<xf:hint ref="$form-resources/k1/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
<xh:td>
<xf:input id="k2-control" bind="k2-bind">
<xf:label ref="$form-resources/k2/label"/>
<xf:hint ref="$form-resources/k2/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
<xh:td>
<xf:input id="v1-control" bind="v1-bind">
<xf:label ref="$form-resources/v1/label"/>
<xf:hint ref="$form-resources/v1/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
</xh:tr>
</fr:grid>
</fr:section>
<fr:section id="section-7-control" bind="section-7-bind">
<xf:label ref="$form-resources/section-7/label"/>
<fr:grid>
<xh:tr>
<xh:td>
<xf:input id="q1-control" bind="q1-bind">
<xf:label ref="$form-resources/q1/label"/>
<xf:hint ref="$form-resources/q1/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
<xh:td>
<xf:input id="q2-control" bind="q2-bind">
<xf:label ref="$form-resources/q2/label"/>
<xf:hint ref="$form-resources/q2/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
<xh:td>
<xf:output id="a1-control" bind="a1-bind">
<xf:label ref="$form-resources/a1/label"/>
<xf:hint ref="$form-resources/a1/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:output>
</xh:td>
</xh:tr>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment