Skip to content
Hub Nexus

No author yetClaim it

Version 1Updated 3 min read

Support

Motivation

You want to demonstrate a typical business application such as the creation of an Invoice. The invoice must have date and Boolean data types and use a bind rule to automatically calculate invoice totals. The invoice should have multiple line items, each with an amount.

Method

We will use many of the standard XForms controls and a standard XForms style sheet to style the form.

Screen Image

(Image: The original uploader was Dmccreary at English Wikibooks ., CC BY-SA 3.0)

Sample Application

Load Sample XForms Application

Sample Invoice Instance

The following is a sample of an invoice document. This document is typically sent by a supplier to a consumer of a product or service after confirmation that the products or services were delivered.

The top portion has items such as an invoice number, the date the invoice was sent to the customer and the from and to information. It is then followed by a set of line items that specify the items delivered and their price. At the end the line items are totaled and an indication made to see if the invoice was paid or not.

123
2008-10-10

Acme Services
123 Main St.
Anytown, MN 12345

Acme Consumer
123 Main St.
Anytown, MN 12345

Widget 123
100.00

Widget 456
200.00

Widget 789
300.00

net-30
false

XForms User Interface

The interface to the Invoice uses input, textarea and select1 controls. In addition, data types are assigned to the InvoiceDate and InvoicePaid indicator elements.

XForms Application Source

xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xf="http://www.w3.org/2002/xforms">

Invoice
rel="stylesheet" type="text/css" href="xforms.css"/>

xmlns="" id="invoice" src="new-instance.xml"/>
nodeset="instance('invoice')/InvoiceDate" type="xs:date"/>
nodeset="instance('invoice')/PaidIndicator" type="xs:boolean"/>
id="total" nodeset="instance('invoice')/TotalAmount" calculate="sum(instance('invoice')/LineItems/Item/Amount)"/>

Invoice

ref="InvoiceID" class="newline">
Invoice Number:

ref="InvoiceDate" class="newline">
Invoice Date:

ref="instance('invoice')/From">
class="group-label">From:
ref="OrganizationName" class="newline">
Company:

ref="OrganizationAddress" class="newline">
Address:

ref="instance('invoice')/To">
class="group-label">To:
ref="OrganizationName" class="newline">
Company:

ref="OrganizationAddress" class="newline">
Address:

class="Description">Description
class="Amount">Amount

nodeset="instance('invoice')/LineItems/Item">
ref="Description" class="Description"/>
ref="Amount" class="Amount"/>

bind="total" class="Amount">
Total:

ref="InvoiceTermsCode" class="newline">
Terms:

Payable on Receipt
payable-on-receipt

Net 30
net-30

2% discount if paid withn 10 days, Net 30
2-10-net-30

Net 60
net-60

ref="PaidIndicator" class="newline">
Paid:

Sample CSS File

The following CSS file required the input XForms application to add the newline class attribute for each control that appears on a new line. This allows the repeat input items to not automatically flow to a new line.

@namespace xf url("http://www.w3.org/2002/xforms");
body {font-family:Helvetica, sans-serif;}
textarea {font-family:Helvetica, sans-serif;}

.newline {display:block; margin:5px 0;}

xf|input > xf|label, xf|select > xf|label, xf|select1 > xf|label, xf|textarea > xf|label
{text-align:right; padding-right:10px; width:20ex; float:left; text-align:right;}

xf|group {border: solid black 1px; margin:15px 5px; padding:5px; background-color:lavender;}
.group-label {text-align:left; font-weight:bold; font-size:12pt;}

/* put each item on a new row */
.xf-repeat-item {padding: 3px; display:block;}

.Description, .Description .xf-value {text-align: left;}
.Description {width: 50ex; text-align: left;}
.Description .xf-value {width: 65ex; text-align: left;}

.Amount, .Amount .xf-value{text-align: right;}
.Amount {width: 12ex;}
.Amount .xf-value {width: 16ex;}

/* add to remove spaces between table cells
table {border-collapse: collapse;} */
thead tr {background-color: silver;}
thead tr th {padding: 2px 5px;}

Where this page came from

This page was imported from Wikibooks. From “XForms” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

Get each new page of

XForms

Following means one email when a page is added, nothing when a page changes.

Following means one email when a page is added, nothing when a page changes.

Comments

Spinner Logo

Next in XForms

CC BY-SA 4.0
One of the classic examples of a web application program is a calculator. ## Program <html xmlns=" xmlns:xf=" xmlns:ev=" <head> <title>Calculator Sample</title> <xf:model> <xf:instance> <equation xmlns=""> <display>0</display> <displaybuffer>0</displaybuffer> <first>0</first> <second>0</second> <mem
CC BY-SA 4.0
id="xforms_cntrl_source_presumed"> appearance="full" ref="instance('taskoutput')/ fe:source_presumed"> undefined undefined_value id="xforms_cntrl_source_information"> appearance="full" ref="instance('taskoutput')/ fe:source_information"> undefined undefined_value id="xforms_cntrl_defendant_reputatio
CC BY-SA 4.0
This is an example of using CSS to format a table without actually using the HTML table element. This is critical since some browsers do not support dynamic tabular layout. The Firefox 0.6 extension also does not support the repeat-nodeset attribute, so you can not yet display repeating data inside
CC BY-SA 4.0
This control displays a different image when a select1 list is selected. ## Screen Image ![XForms-custom-control]( (Image: The original uploader was Dmccreary at English Wikibooks ., CC BY-SA 3.0) ## Sample Program <html xmlns=" xmlns:xf=" <head> <title>Custom Image Control Sample</title> <bindings
CC BY-SA 4.0
function dirty() { setBunload(true); } function clean() { setBunload(false); } This one goes in your "submission" element: resource="javascript:clean()" ev:event="xforms-submit-done"/> and this resource="javascript:dirty()" ev:event="xforms-value-changed"/> goes somewhere in the form - place it at t
CC BY-SA 4.0
I have tried to use the current() function inside the repeat like this: ref="current()/@selected" value="'false'" /> but with no luck. If anyone knows how to get this working, please let us know. Thanks - Dan ### Alternate Way Note: does not work inside . Here is the workaround for this.