Skip to content

Instantly share code, notes, and snippets.

@terrancesnyder
Created July 4, 2011 16:40
Show Gist options
  • Save terrancesnyder/1063597 to your computer and use it in GitHub Desktop.
Save terrancesnyder/1063597 to your computer and use it in GitHub Desktop.
Example of a static loaded tree view control.
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xforms="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:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:exforms="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/">
<xhtml:head>
<xhtml:title>Example Tree Control</xhtml:title>
<xforms:model id="fr-form-model">
<!-- Main instance -->
<xforms:instance id="fr-form-instance">
<form>
<static>
<tree1/>
</static>
</form>
</xforms:instance>
<!-- static data for the static tree -->
<xforms:instance id="sample-tree-data">
<items>
<item label="Encyclopedia" folder="true" value="en">
<item label="Science" folder="true" value="sc"/>
<item label="Culture" folder="true" value="cu">
<item label="Art" folder="false" value="ar"/>
<item label="Craft" folder="false" value="cr"/>
</item>
</item>
</items>
</xforms:instance>
<!-- Bindings -->
<xforms:bind id="fr-form-binds" nodeset="instance('fr-form-instance')">
<xforms:bind id="static-bind" nodeset="static" name="static">
<xforms:bind id="tree1-bind" nodeset="tree1" name="tree1"/>
</xforms:bind>
</xforms:bind>
<!-- Metadata -->
<xforms:instance id="fr-form-metadata" xxforms:readonly="true">
<metadata>
<application-name>example</application-name>
<form-name>tree</form-name>
<title xml:lang="en">Example Tree Control</title>
<description xml:lang="en">Shows an example of using a tree view with external data loaded at runtime.</description>
<author/>
<logo mediatype="" filename="" size=""/>
</metadata>
</xforms:instance>
<!-- Attachments -->
<xforms:instance id="fr-form-attachments">
<attachments>
<css mediatype="text/css" filename="" size=""/>
<pdf mediatype="application/pdf" filename="" size=""/>
</attachments>
</xforms:instance>
<!-- All form resources -->
<!-- Don't make readonly by default in case a service modifies the resources -->
<xforms:instance id="fr-form-resources" xxforms:readonly="false">
<resources>
<resource xml:lang="en">
<tree1>
<label>Static Tree</label>
<hint>An Example of a Static Loaded tree</hint>
<help/>
<alert/>
</tree1>
<static>
<label>101 Level - Static Example</label>
<help/>
</static>
</resource>
</resources>
</xforms:instance>
<!-- Utility instances for services -->
<xforms:instance id="fr-service-request-instance" xxforms:exclude-result-prefixes="#all">
<request/>
</xforms:instance>
<xforms:instance id="fr-service-response-instance" xxforms:exclude-result-prefixes="#all">
<response/>
</xforms:instance>
</xforms:model>
</xhtml:head>
<xhtml:body>
<fr:view>
<xforms:label ref="instance('fr-form-metadata')/title"/>
<fr:body>
<fr:section id="static-section" bind="static-bind">
<xforms:label ref="$form-resources/static/label"/>
<xforms:help ref="$form-resources/static/help"/>
<fr:grid columns="2">
<xhtml:tr>
<xhtml:td>
<xforms:select xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary"
appearance="xxforms:tree"
bind="tree1-bind"
incremental="true"
id="tree1-control">
<xforms:label ref="$form-resources/tree1/label"/>
<xforms:hint ref="$form-resources/tree1/hint"/>
<xforms:help ref="$form-resources/tree1/help"/>
<xforms:alert ref="$fr-resources/detail/labels/alert"/>
<xforms:itemset nodeset="instance('sample-tree-data')//item">
<xforms:label ref="@label"/>
<xforms:value ref="@value"/>
</xforms:itemset>
</xforms:select>
</xhtml:td>
<xhtml:td/>
</xhtml:tr>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xhtml:body>
</xhtml:html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment