Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Getting Started with XForms in OpenOffice : Page 2

Discover how to design and customize XForms in OpenOffice.


advertisement
Creating XForms in OpenOffice
The XForms in OpenOffice implementation focuses on simple forms that end users can design themselves. This article provides a limited example of how an end user could use OpenOffice's design mode to build a form, including discussions of the XForms syntax, and common problems that users may encounter.
 
Figure 1. Creating a New XForms Document: The figure shows the menu command sequence for creating a new XML Form (XForms) document in OpenOffice Writer.

The first step is to create an XForms document. To do that, open a new instance of OpenOffice Writer and choose the menu path File → New → Xml Form Document (press Alt-f → n → x). You'll see something similar to Figure 1.

Your newly-created XForm is a normal OpenOffice document, but accompanied by a set of form controls floating on the screen, probably in the upper left corner, as shown in Figure 2, and an open panel on the right side of the screen as shown in Figure 3.

Figure 2. OpenOffice Form Controls: After creating or opening an XML Forms document, you'll see a Controls panel containing controls you can place on the form.
Figure 3. The XForms Model Panel: The Model panel shows your instance data.

If you don't see the form control shown in Figure 2, you can enable it by following the menu path View → Toolbars → Form Controls.

When you initially create the XForm, the document will be in design mode; you can toggle design mode off and on by clicking the icon at the top right-hand corner of the form controls panel shown in Figure 2. At this point you have an XForm with XML data inside of it. The document element of this XForms instance is the default instanceData element you can see in Figure 3.



 
Figure 4. Adding an Element: You add elements to your form's instance data through the Add Element dialog.
Right click on instanceData in the Model panel, and choose add element. Doing so pops up a form resembling Figure 4. Add the element AddressPostal. Notice that there's no namespace associated with the element. That's a problem, because you can easily create a malformed instance by using a name with a namespace prefix that has no corresponding namespace association. For example, if you entered xkom:AddressPostal in the name field, the dialog will not prompt you in any way to define the namespace to which the xkom prefix is bound.

The XForms Model panel (see Figure 3) has three tabs, named "Instance 1," "Submissions," and "Bindings." Each tab has a number of icons beneath it, the middle one of which is an edit icon. In the "Instance 1" tab you can edit a selected element by choosing the middle "Edit Element" icon. Rather confusingly, to add namespaces to your instance you don't choose the Edit Element icon in the first tab; instead, you add namespaces by editing a binding expression from either the Submissions or Bindings tab. To do this, choose the "Bindings" tab, then the middle edit bindings icon, then the "Edit Binding Expression" button on the form that pops up. That pops up another form, where you choose "Edit Namespaces." Finally, that form provides a list view where you can add namespaces and associate them with a prefix.

Figure 5 shows the forms that appear when you want to edit namespaces.

 
Figure 5. Adding Namespaces: You add namespaces to your instance via a roundabout sequence of steps to arrive at the "Namespaces for Forms" dialog.

As you can see, the UI has an inconvenient and counter-intuitive method for adding namespaces. For the example in this article, you won't need to add namespaces or use that portion of the UI, but at least you now know how to get to the feature.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap