A Real-World Example

As an example, this section will develop an XForms solution for creating and editing a UBL purchase order. The first step is to define the initial instance data, which is a skeleton XML document that contains the complete structure of the desired final document, but with only initial data. This document serves as a template for newly-created purchase orders, and provides a framework on which to hang the rest of the form.

Tip

This complete example form is available online at http://dubinko.info/writing/xforms/ubl/.

Example 2-1 shows what a UBL purchase order document looks like. Figure 2-1 shows, in the X-Smiles browser, an XForms document capable of creating such a document.

An XML purchase order being created with XForms

Figure 2-1. An XML purchase order being created with XForms

Example 2-1. An XML purchase order using UBL

<Order xmlns="urn:oasis:names:tc:ubl:Order:1.0:0.70" xmlns:cat="urn:oasis:names:tc:ubl:CommonAggregateTypes:1.0:0.70"> <cat:ID/> <cat:IssueDate/> <cat:LineExtensionTotalAmount currencyID="USD"/> <cat:BuyerParty> <cat:ID/> <cat:PartyName> <cat:Name/> </cat:PartyName> <cat:Address> <cat:ID/> <cat:Street/> <cat:CityName/> <cat:PostalZone/> <cat:CountrySub-Entity/> </cat:Address> <cat:BuyerContact> <cat:ID/> <cat:Name/> </cat:BuyerContact> </cat:BuyerParty> <cat:SellerParty> <cat:ID/> <cat:PartyName> <cat:Name/> </cat:PartyName> <cat:Address> <cat:ID/> <cat:Street/> <cat:CityName/> <cat:CountrySub-Entity/> ...

Get XForms Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.