XForms/Tri-Document Loading

Motivation
You want to allow a user to process a document in one of three ways:


 * 1) by using a copy/paste from a text document
 * 2) by uploading a file from a local file system
 * 3) by referencing a URL

Method
We will use a combination of the switch/case with three tabs. The first tab will be for a textarea, the second for a upload control and the third for a URL.

Screen Image


The first control on the first tab uses the XForms "textarea" control. This allows users to copy and paste text into a document. The second tab uses an upload control. The upload control will take any file and convert it to a text-encoded XML file. The last tab allows the user to just submit a URL. This URL can then be stored directly into a database or the content can be extracted with other tools.

Depending on different conditions you may want one or more of these controls to be used. The textarea might be the most useful if the content of the document needs to be searched. The other two controls might require a server-side process to extract text for search.

Source Code
   Text   Upload   URL     Text:  <xf:textarea ref="text" class="textarea-big"/> </xf:case> <xf:case id="case-2"> <xf:upload ref="binary"> <xf:label>Upload: </xf:label> <xf:filename>file:///C:/tmp/*.xml</xf:filename> <xf:mediatype>text/xml</xf:mediatype> </xf:upload> </xf:case> <xf:case id="case-3"> <xf:input ref="url" class="url"> <xf:label>URL: </xf:label> </xf:input> </xf:case> </xf:switch> <xf:output ref="text"> <xf:label>Text: </xf:label> </xf:output> <xf:output ref="binary"> <xf:label>Binary: </xf:label> </xf:output> <xf:output ref="url"> <xf:label>URL: </xf:label> </xf:output> <xf:submit submission="save"> <xf:label>Save</xf:label> </xf:submit>