Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ebruchez
Created March 22, 2012 05:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ebruchez/2156397 to your computer and use it in GitHub Desktop.
Save ebruchez/2156397 to your computer and use it in GitHub Desktop.
Prototype for XBL component with binding to optional element
<xbl:xbl xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:xxbl="http://orbeon.org/oxf/xml/xbl">
<xbl:binding id="fr-optional-element" element="fr|optional-element" xxbl:mode="binding handlers" xxbl:container="span">
<xbl:template>
<xforms:group appearance="xxforms:internal">
<!-- Content such as xforms:input -->
<xbl:content/>
<!-- Insert element if missing -->
<xforms:action ev:event="xforms-enabled" ev:target="#observer">
<xforms:var name="ref" xbl:attr="xbl:text=ref"/>
<xforms:var name="name" value="tokenize($ref, '/')[last()]"/>
<xforms:insert
if="not(exists(xxforms:binding('fr-optional-element'))) and $name castable as xs:NCName"
context="xxforms:component-context()"
ref="*"
origin="xxforms:element($name)"/>
</xforms:action>
</xforms:group>
</xbl:template>
</xbl:binding>
</xbl:xbl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment