public
Last active

Prototype for XBL component with binding to optional element

  • Download Gist
gistfile1.xml
XML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
<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>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.