XForms to XHTML+Javascript (AJAX) conversion based on a unique XSL transformation. Suitable server-side (PHP) or client-side (Google Chrome, Edge, Internet Explorer, Mozilla FireFox, Opera, Safari) browser treatment where an XSLT 1.0 engine is available
I have a form sketch where subforms are embedded into the main form. However, there are complications:
if subform failed to be found, then the user should be notified about the error
user has to be able to dismiss the subform either by accepting or rejecting it
Here's the main form (showform3_load.xml):
<?xml-stylesheet href="/xsltforms/xsltforms.xsl" type="text/xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events">
<head>
<title>Main Form</title>
<xforms:model>
<xforms:instance>
<data xmlns=""/>
</xforms:instance>
<!-- FIXME: these actions are only run once (probably get removed on subform unload?) -->
<xforms:action ev:event="xforms-link-exception" ev:observer="subform">
<xforms:message>
Failed to obtain the subform at: <xforms:output value="event('resource-uri')"/>,
error code: <xforms:output value="event('response-status-code')"/>,
error reason: <xforms:output value="event('response-reason-phrase')"/>
</xforms:message>
</xforms:action>
<xforms:action ev:event="xforms-load-done" ev:observer="subform">
<xforms:message>Load Success!</xforms:message>
<xforms:toggle case="form-sub"/>
</xforms:action>
</xforms:model>
</head>
<body>
<xforms:switch id="form-switch">
<!-- this is the "main" form -->
<xforms:case id="form-main">
<h2>Main form</h2>
<xforms:trigger>
<xforms:label>Open subform 1</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:message>Opening subform 1</xforms:message>
<xforms:load show="embed" targetid="subform" resource="showform3_subform1.xml"/>
</xforms:action>
</xforms:trigger>
<xforms:trigger>
<xforms:label>Open subform 2</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:message>Opening subform 2</xforms:message>
<xforms:load show="embed" targetid="subform" resource="showform3_subform2.xml"/>
</xforms:action>
</xforms:trigger>
</xforms:case>
<!-- this is the portion of the form that we will be using for subforms (e.g. Edit subform) -->
<xforms:case id="form-sub">
<xforms:trigger>
<xforms:label>Accept Subform</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:message>Accepting Subform</xforms:message>
<xforms:unload targetid="subform"/>
<xforms:toggle case="form-main"/>
</xforms:action>
</xforms:trigger>
<!-- this actually does what we want, but the subform *by itself*
is invalid (there is no such targetid in the subform!
-->
<xforms:trigger>
<xforms:label>Reject Subform</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:message>Rejecting Subform</xforms:message>
<xforms:unload targetid="subform"/>
<xforms:toggle case="form-main"/>
</xforms:action>
</xforms:trigger>
<xforms:group id="subform"/>
</xforms:case>
</xforms:switch>
</body>
</html>
Hello,
I have a form sketch where subforms are embedded into the main form. However, there are complications:
Here's the main form (showform3_load.xml):
Here is subform 1 (showform3_subform1.xml):
And finally, here is subform 3 (showform3_subform2.xml):
To reproduce:
Please help me figure this one out.