65
Slide 1 © Copyright 2007, IBM Corporation Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model Colorado Software Summit: October 21 – 26, 2007 How I Learned to Stop Worrying and Love the Data Model Doug Tidwell IBM Corporation dtidwell@us . ibm .com

Colorado Software Summit: October 21 – 26, 2007 How I ... · Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model Advantages of XForms XForms has an underlying

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Slide 1

© Copyright 2007, IBM Corporation

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Colorado Software Summit: October 21 – 26, 2007

How I Learned to StopWorrying and Love theData Model

Doug Tidwell

IBM Corporation

[email protected]

© Copyright 2007, IBM Corporation

Slide 2

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Objectives

Introduce XForms, an open standardfor business forms

Discuss the advantages of declarativeprogramming

Illustrate the differences betweenXForms and more traditional AJAXapproaches

Examine ways to deploy XForms

© Copyright 2007, IBM Corporation

Slide 3

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

The paradigm

If you need to do CRUD operationswith an XML document type, useXForms.

An XForms document is a customapplication built around your XMLdocument.

Slide 4

© Copyright 2007, IBM Corporation

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Colorado Software Summit: October 21 – 26, 2007

XForms

The next generation of formson the Web

© Copyright 2007, IBM Corporation

Slide 5

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

XForms

A W3C effort to “bring HTML forms intothe 20th century”

Forms should be integrated with datamodels

One form should be renderable onmany types of devices

Use a declarative model as much aspossible

© Copyright 2007, IBM Corporation

Slide 6

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

HTML forms - weaknesses

Based solely on appearance

Non-Western character support isspotty

Cross-device forms are very difficult towrite

Reliance on scripting

No real data model

© Copyright 2007, IBM Corporation

Slide 7

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

XForms at the W3C

XForms Version 1.0 became an officialW3C Recommendation in October2003.

The latest revision to V1.0 was in March2006.

Version 1.1 is currently in Last Call atthe W3C.

The last draft was published in February2007.

© Copyright 2007, IBM Corporation

Slide 8

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Advantages of XForms

XForms has an underlying data modelthat can be generated from yourexisting business objects.

XForms has an underlying data modelthat can be generated from yourexisting business objects.

XForms has an underlying data modelthat can be generated from yourexisting business objects.

© Copyright 2007, IBM Corporation

Slide 9

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Why is XForms so important?

We’re creating more new XML datathan new relational data

Growing at 2X rate of total databasemarket [IDC]

All major relational database vendorshave some form of XML support

XML is now pervasive in manyorganizations

Almost every sector has XML basedstandards

© Copyright 2007, IBM Corporation

Slide 10

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Structure of an XForms file

XForms tags are justXML tags imbedded in astandard XHTML filewith a differentnamespace

Most HTML form tagsare exactly the same

Namespaces

CSS Imports (View)

Model

Constraints (Bindings)

UI (View)

Submit

© Copyright 2007, IBM Corporation

Slide 11

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Separation of concerns

Model is in the header (non-visual section)Visual components are in the body (presentation)

<html>

<head>

</head>

<body>

</body>

</html>

XForms modelBusiness Model

(non-visible)

Content

Presentation

Form controls

© Copyright 2007, IBM Corporation

Slide 12

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

XForms is model-driven

XForms enables thedeveloper to reuse businessrules encapsulated in XMLSchemas (XSD) and XMLTransformations (XSLT)

XForms reduces duplicationand ensures that a changein the underlying businesslogic does not requirerewriting in anotherlanguage

XML

Schema

Meta

Data

Registry

XForms

Application

© Copyright 2007, IBM Corporation

Slide 13

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Model-View-Controller

XForms uses a variationof the model-view-controller (MVC) designpattern

The model has no userinterface concepts

The control layer movesdata to and from themodel

View

(Presentation)

Control

Model

© Copyright 2007, IBM Corporation

Slide 14

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Strong typing

Submitted data can be strongly typedif necessary and can be checked on theclient

Strong typing enables automatic client-side validation

When serving the same XForms documentto an non-compliant browser, theseconstraints can be used to generate client-side JavaScript automatically

© Copyright 2007, IBM Corporation

Slide 15

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Beyond XML Schema

XForms authors can go beyond thebasic set of XML Schema constraintsand add complex validation rules

XForms provides additional constraintsas part of the Model

This enhances the overallmanageability of the resulting Webapplications

© Copyright 2007, IBM Corporation

Slide 16

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Direct XML submission

XML Forms can send XML data directly fromthe web client to the server

Data can be validated directly in the clientweb browser

Complex multi-part forms can be brokendown into tabs but do not need re-fetchingfrom the server

© Copyright 2007, IBM Corporation

Slide 17

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Direct XML submission

There is no need for custom server-side logic to transform the submitteddata to the business application if italready uses XML

XML submission is like AJAX++ - it has alot of configurability. You can submit afragment, prune elements, you can turnvalidation, etc. on or off in 1.1.

You can work with XML on the client side,but you can still submit to non-XMLsystems on the server side.

© Copyright 2007, IBM Corporation

Slide 18

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Device independence

Abstract user interfacecontrols lead to intent-based authoring of theuser interface

An XForms application cantarget many differentdevices

XForms can be deployed toa range of accessingdevices

Look at PicoForms, Satec

© Copyright 2007, IBM Corporation

Slide 19

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

A brief tour of XForms

We’ll spend a few minutes looking atsome of the capabilities of XForms.

The Tax Form and other samples are atmozilla.org/projects/xforms/samples.html

To see the Orbeon samples, installOrbeon, start your servlet container andgo to http://localhost:8080/ops.

Slide 20

© Copyright 2007, IBM Corporation

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Colorado Software Summit: October 21 – 26, 2007

Declarative programming

© Copyright 2007, IBM Corporation

Slide 21

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Declarative programming

Declarative programming says what has tobe done; it doesn’t say how to do it.

Works in the context of a particular problem

We want to get the information about a customerliving in the United States, for example.

The requirements of that problem can beencoded in a specialized language

Define that language as XML; from there, you cangenerate an XML Schema, the XForms userinterface, test data, etc.

© Copyright 2007, IBM Corporation

Slide 22

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Problem contextIf we’re issuing an insurance policy to aperson living in the United States:

We know the format of the person’s name

We know the format of the person’s address

Maybe we need other details about thatperson

What organization they work for (we havediscounts for employees of certain companies)

Are US citizens?

We use datatypes to define the informationA person’s name is a string, their date of birth isa date, a yes or no question is a boolean, etc.

© Copyright 2007, IBM Corporation

Slide 23

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Defining business objects

Given our knowledge of the context,we can define business objects. Here’sa person in the U.S.:

Title (optional): Dr., Mr., Mrs., Ms., Rev.

First name

Middle name (optional)

Last name

Suffix (optional): Jr., Sr., II, III, IV

We can define all of these with XMLSchema.

© Copyright 2007, IBM Corporation

Slide 24

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Generating user interfaces

Given our business object, it’s easy togenerate a user interface with XForms.

Everything in the form is mapped directly tosomething in the XML schema.

Slide 25

© Copyright 2007, IBM Corporation

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Colorado Software Summit: October 21 – 26, 2007

XForms documentstructure

© Copyright 2007, IBM Corporation

Slide 26

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

An XML document… is a tree

Both the model and theviews are trees of dataelements.

root

branch branch

leaf leaf branch

branch

leaf

leaf leaf

leaf

branch

leaf leaf

branch

…branch

leaf

© Copyright 2007, IBM Corporation

Slide 27

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

The XHTML… is a tree

HTML

head body

title style form

fieldset

h1

label input

meta

fieldset

label input

p form

…xf:model

Both the model and theviews are trees of dataelements.

© Copyright 2007, IBM Corporation

Slide 28

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

The model… is a tree

xf:model

OrganizationPerson

Name

FirstName

LastName

Address

Street City

State Zip

HTML

head

title stylemeta

body

© Copyright 2007, IBM Corporation

Slide 29

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Linking the model and view

xf:model

Person

Name

HTML

head

body

Person

Name

…form

fieldset

label

FirstName

LastName

input

label

input<bind> <bind>

© Copyright 2007, IBM Corporation

Slide 30

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Just do the right thing

xf:model

Person

HTML

head

body

Person…

…form

fieldset

label

BirthDate type="xs:date"

USCitizen type="xs:boolean"

input

label

input<bind> <bind>

Slide 31

© Copyright 2007, IBM Corporation

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Colorado Software Summit: October 21 – 26, 2007

XFormscompared to AJAX

© Copyright 2007, IBM Corporation

Slide 32

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

XForms compared to AJAX

AJAX doesn’t have a built-in datamodel

AJAX uses JavaScript for everything

AJAX doesn’t automatically generateXML data

© Copyright 2007, IBM Corporation

Slide 33

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

XForms has a data model

xf:model

OrganizationPerson

Name

FirstName

LastName

Address

Street City

State Zip

HTML

head

title stylemeta

body

© Copyright 2007, IBM Corporation

Slide 34

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

AJAX doesn’t

HTML

head

title stylemeta

body

© Copyright 2007, IBM Corporation

Slide 35

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

XForms doesn’t need JS

xf:model

Person

HTML

head

body

Person…

…form

fieldset

label

BirthDate type="xs:date"

USCitizen type="xs:boolean"

input

label

input<bind> <bind>

© Copyright 2007, IBM Corporation

Slide 36

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

AJAX has to use JSHTML

head

body

form

fieldset

label

input

label

input

script

FirstName =

document.person.first;

LastName =

document.person.last;

CurrentOnTaxes =

document.person.cot.checked;

DateOfBirth =

new Date(document.person...)

© Copyright 2007, IBM Corporation

Slide 37

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

label label

XForms generates XML

form

fieldset

BirthDate type="xs:date"

USCitizen type="xs:boolean"

input input<bind> <bind>

<Person>

<Name>. . .</Name>

<Organization>. . .</Organization>

<BirthDate>1995-04-21</BirthDate>

<USCitizen>true</USCitizen>

</Person>

© Copyright 2007, IBM Corporation

Slide 38

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

AJAX has to use JSHTML

head

body

form

fieldset

label

input

label

input

script

// Build XML structure

// by hand; use JSON? DOM?

// Create element "Person"

// Create element "FirstName"

// Create text element "Bob"

// Add text element as child

// of "FirstName" . . .

Slide 39

© Copyright 2007, IBM Corporation

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Colorado Software Summit: October 21 – 26, 2007

Building and deployingXForms

© Copyright 2007, IBM Corporation

Slide 40

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Building and deploying

One of the challenges of deployingXForms is viewing them.

We’ll look at three approaches:

Requiring a browser plug-in

Generating JavaScript from the XFormsdocument

Using a standalone viewer

© Copyright 2007, IBM Corporation

Slide 41

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Forms Players

<html>

<head>

<xf:model>

<xf:/model>

<head>

<body>

<xf:input>

</xf:input>

</body>

</html>

Rendered

Form

XForms

Players

XForms

Extension

Mobile Client

Presentation Server

Netfront Mobile

See Wikipedia “XForms”

© Copyright 2007, IBM Corporation

Slide 42

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Using a browser plug-in

Typically useful in an intranet

For Internet Explorer, there are someoptions:

•FormsPlayer by Mark Birbeck

•MozzIE, written by Peter Nunnsourceforge.net/projects/mozzie

Mozilla has an XForms plug-in; it’savailable at:https://addons.mozilla.org/en-US/firefox/addon/824

© Copyright 2007, IBM Corporation

Slide 43

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Using Ajax controls

The Chiba project provides an open-source XForms engine.

It uses XSLT to transform the XFormsdocument into Ajax-enabled HTML pagesand send them to the client.

The Orbeon Presentation Server (OPS)is based on Chiba and provides similarfunctions.

These are server-centric. They cangenerate some client-side validation.

© Copyright 2007, IBM Corporation

Slide 44

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Using a standalone viewer

A third option is to use a standaloneviewer that renders the XForms andmanages the data stored in the model.

FormsPlayer is a good example of thisapproach.

You can embed the FormsPlayer inside a.Net application.

Slide 45

© Copyright 2007, IBM Corporation

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Colorado Software Summit: October 21 – 26, 2007

A Web 2.0 UI

© Copyright 2007, IBM Corporation

Slide 46

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Data models

Lost in all the excitement of Web 2.0 isthe fact that our spiffy interfaces haveto do something useful.

You can build Web pages withJavaScript libraries to put a happy faceon a business process

Are these maintainable? Probably not.

We want these pages to be tied to ourdata model.

© Copyright 2007, IBM Corporation

Slide 47

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Our data models

© Copyright 2007, IBM Corporation

Slide 48

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

The application

© Copyright 2007, IBM Corporation

Slide 49

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

The application

© Copyright 2007, IBM Corporation

Slide 50

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

The application

I wrote an article about using XSLT togenerate the bracket from the XMLdocument:ibm.com/developerworks/xml/library/x-xslt20xpath20/

An article about building the XFormsapplication will be published on dWsoon.

© Copyright 2007, IBM Corporation

Slide 51

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

The new paradigm

An XForms documentis a custom editor

for your XMLdocument type.

Slide 52

© Copyright 2007, IBM Corporation

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Colorado Software Summit: October 21 – 26, 2007

Resources

© Copyright 2007, IBM Corporation

Slide 53

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Resources

The XForms 1.1 spec:w3.org/TR/xforms11/ [Last call draft]

XForms 1.0:w3.org/TR/xforms/

Steven Pemberton’s XFormspresentation on the W3C site:w3.org/2007/Talks/05-15-steven-xforms11/

© Copyright 2007, IBM Corporation

Slide 54

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Resources

XForms.org

XForms Institute:xformsinstitute.com/

O’Reilly’s XML.org

IBM developerWorks:ibm.com/developerworks/xml/xforms

© Copyright 2007, IBM Corporation

Slide 55

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Resources

MozzIE:sourceforge.net/projects/mozzie

Embeds the Mozilla Gecko renderingengine into IE

Firefox XForms add-on:

Select Tools Add-ons, then click GetExtensions, search for “XForms”

https://addons.mozilla.org/en-US/firefox/addon/824

© Copyright 2007, IBM Corporation

Slide 56

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Resources

FormFaces:formfaces.com

Chiba:chiba.sourceforge.net

Orbeon Presentation Server:

Available at orbeon.com, open-sourced

under the GPL

© Copyright 2007, IBM Corporation

Slide 57

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Resources

FormsPlayer:formsplayer.com

Also see Mark Birbeck’s Introduction toXForms at:formsplayer.com/introduction-to-xforms

© Copyright 2007, IBM Corporation

Slide 58

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Resources

Visual XForms Designer:ibm.com/alphaworks/tech/vxd

XML Forms Generator:ibm.com/alphaworks/tech/xfg

© Copyright 2007, IBM Corporation

Slide 59

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

XForms Tutorial & Cookbook

An excellent tutorialon XForms

Includes dozens ofworking samples thatillustrate the fullpower of XForms.en.wikibooks.org/wiki/XForms

© Copyright 2007, IBM Corporation

Slide 60

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

XForms Essentials

Micah Dubinko was oneof the editors of theXForms 1.0 spec.

You can get an onlinecopy of his book atxformsinstitute.com/essentials/

The DocBook source isavailable as well.

ISBN 978 0596003692.

Slide 61

© Copyright 2007, IBM Corporation

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Colorado Software Summit: October 21 – 26, 2007

A brief ethics test

© Copyright 2007, IBM Corporation

Slide 62

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Is it ethical… No!

…to mention thesecond edition ofmy book is on itsway? (ISBN 0-596-51415-8)

Lists for $49.99, butit’s a bargain attwice the price.

Rough Cuts versionavailable today!

Slide 63

© Copyright 2007, IBM Corporation

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Colorado Software Summit: October 21 – 26, 2007

Summary

© Copyright 2007, IBM Corporation

Slide 64

Colorado Software Summit: October 21 – 26, 2007

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Summary

We’ve covered several importanttopics:

XForms, an open standard for forms

Declarative programming

Differences between XForms and AJAX

How to deploy XForms

Slide 65

© Copyright 2007, IBM Corporation

Doug Tidwell – How I Learned to Stop Worrying and Love the Data Model

Colorado Software Summit: October 21 – 26, 2007

Thanks!

Doug Tidwell

IBM Corporation

[email protected]