Skip to content

Instantly share code, notes, and snippets.

Created November 21, 2012 11:47
Show Gist options
  • Save anonymous/4124498 to your computer and use it in GitHub Desktop.
Save anonymous/4124498 to your computer and use it in GitHub Desktop.
This form tests the stable scope of xpath in an XForms implementation
<?xml version="1.0" encoding="UTF-8"?>
<xhtml:html
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:ev = "http://www.w3.org/2001/xml-events"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:idc="http://www.inventivedesigners.com/xbl"
xmlns:xi="http://www.w3.org/2001/XInclude">
<xhtml:head>
<xhtml:title>Test XPath stable scope</xhtml:title>
<xf:model id="m-default">
<!-- Instance that holds all jobs -->
<xf:instance id="i-default" xxf:read-only="true">
<root xmlns="">
<date-time-model-construct-done></date-time-model-construct-done>
<date-time-model-calculate></date-time-model-calculate>
<date-time-model-calculate-dependant></date-time-model-calculate-dependant>
<date-time-model-required>foo</date-time-model-required>
</root>
</xf:instance>
<xf:bind id="b-date-time-model-calculate" ref="date-time-model-calculate" calculate="now()" />
<xf:bind id="b-date-time-model-calculate-dependant" ref="date-time-model-calculate-dependant" calculate="../date-time-model-calculate" />
<!-- <xf:bind id="b-date-time-model-required" ref="date-time-model-required" required="seconds-from-dateTime(date-time-model-construct-done) &lt; (seconds-from-dateTime(now()) - 5)" /> -->
<xf:bind id="b-date-time-model-required" ref="date-time-model-required" required="seconds-from-dateTime(xs:dateTime(date-time-model-construct-done)) &lt; (seconds-from-dateTime(xs:dateTime(now())) - 5)" />
<xf:setvalue ev:event="xforms-model-construct-done" ref="date-time-model-construct-done" value="now()" />
</xf:model>
</xhtml:head>
<xhtml:body>
<xhtml:div>
<xf:trigger>
<xf:label>Rebuild</xf:label>
<xf:rebuild ev:event="DOMActivate"/>
</xf:trigger>
<xf:trigger>
<xf:label>Recalculate</xf:label>
<xf:recalculate ev:event="DOMActivate"/>
</xf:trigger>
<xf:trigger>
<xf:label>Revalidate</xf:label>
<xf:revalidate ev:event="DOMActivate"/>
</xf:trigger>
<xf:trigger>
<xf:label>Refresh</xf:label>
<xf:refresh ev:event="DOMActivate"/>
</xf:trigger>
<xf:trigger>
<xf:label>Action</xf:label>
<xf:message ev:event="DOMActivate"><xf:output value="now()"/></xf:message>
</xf:trigger>
</xhtml:div>
<xhtml:div>
<xf:output value="now()">
<xf:label>UI binding: </xf:label>
</xf:output>
</xhtml:div>
<xhtml:div>
<xf:output bind="b-date-time-model-calculate">
<xf:label>Bind calculate: </xf:label>
</xf:output>
</xhtml:div>
<xhtml:div>
<xf:output bind="b-date-time-model-calculate-dependant">
<xf:label>Bind calculate dependant: </xf:label>
</xf:output>
</xhtml:div>
<xhtml:div>
<xf:output ref="date-time-model-construct-done">
<xf:label>Model construct done: </xf:label>
</xf:output>
</xhtml:div>
<xhtml:div>
<xf:input bind="b-date-time-model-required">
<xf:label>Required after 5sec: </xf:label>
</xf:input>
</xhtml:div>
</xhtml:body>
</xhtml:html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment