XForms Submission
XForms submission relies on three templates. The first is the
submitForm template:
<xsl:template name="submitForm">
<xforms:submission id="submitForm"
action="file:///{concat($outputpath,$outputfile)}"
method="put" indent="true" omit-xml-declaration="false"
standalone="false" replace="none">
</xforms:submission>
</xsl:template>
The
submitForm template generates the Xforms submission binding, and in this case associates it with an action to output to the
file protocol, via the
action attribute. That requires two global parameters:
outputpath and
outputfile. If, instead of using an XSLT Filter, you transformed your input XML via your own code for calling transformations, you could set the value of these global parameters in your code and then place the output ODF into the zipped file format that OpenOffice uses.
The drawn control for the submission button to be bound to is in the template matching the root node (the first template in the stylesheet). The relevant fragment below shows the drawn element with button positioning:
<draw:control text:anchor-type="paragraph"
draw:style-name="defaultsubmit"
draw:text-style-name="P2" svg:width="3.116cm"
svg:height="0.851cm" draw:control="submittercontrol"/>
Finally, here's the template that controls the form button.
<xsl:template name="form-button">
<form:button form:name="PushButton"
form:control-implementation=
"ooo:com.sun.star.form.component.CommandButton"
form:id="submittercontrol" form:label="Button"
form:button-type="submit" form:xforms-submission="submitForm"
>
<form:properties>
<form:property form:property-name="DefaultControl"
office:value-type="string"
office:string-value=
"com.sun.star.form.control.CommandButton"/>
</form:properties>
</form:button>
</xsl:template>
Note that in most XForms customization cases in OpenOffice, you can add customization in three places:
- At the XForms namespaced elements
- At the forms namespaced elements
- At the drawn elements inputs
This rule also holds true for customizing the submission button.
Customization Possibilities
A number of customization possibilities exist for extending the generic transformation, including:
- Customization at the level of matching specific input elements or attributes
- Customizing the default behavior
- Customization of the generated OpenOffice styles
- Customizing the default objects generated in the output
Some obvious customizations are to make the XForms Instance output filename dependent on the value of a form field, or to make it submit to an HTTP address using
post, or perhaps to require form fields to be generated only for XML elements or attributes that do not already have a value.