22
1 © Copyright 2008 IBM Corporation. XForms: The Perfect Front-End XForms: The Perfect Front-End to Your Composite Application to Your Composite Application Doug Tidwell, IBM [email protected]

SLIDES

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: SLIDES

11© Copyright 2008 IBM Corporation.

XForms: The Perfect Front-End XForms: The Perfect Front-End to Your Composite Application to Your Composite Application

Doug Tidwell, [email protected]

Page 2: SLIDES

2© Copyright 2008 IBM Corporation.

The problemThe problem

• We need interfaces to create, edit and update XML documents.– XML documents are at the heart of tens of thousands

of Web services applications.– XML documents are at the heart of every human

interaction with a business process (BPEL).– It’s easier to create XML than it is to create some

other document format and then convert it to XML.

• We need some way to create interfaces for XML documents.

Page 3: SLIDES

3© Copyright 2008 IBM Corporation.

Some approaches to this problemSome approaches to this problem

• We could edit the XML by hand in emacs, vi, Notepad, or some equally unfriendly tool.– Very error-prone, particularly for complicated XML

document types– Acceptable to geeks only

• We could write a graphical application that used various kinds of controls to edit the XML behind the scenes.– Very high cost of development – We still have to write the code to map values

selected in each control to something in the XML document

– Difficult to maintain as the XML document structure changes

Page 4: SLIDES

4© Copyright 2008 IBM Corporation.

Some approaches to this problemSome approaches to this problem

• We could write an HTML page with our favorite AJAX library.– Faster than building a graphical application, but…– We still have to write the code to map values selected

in each control to something in the XML document– Difficult to maintain as the XML document structure

changes

• We could use XForms.– Similar development time compared to AJAX– XForms has a built-in data model (unlike everything

else we’ve mentioned)– Interface controls are tied directly to the XML– Much easier to maintain as the XML structure changes.

Page 5: SLIDES

5© Copyright 2008 IBM Corporation.

The paradigmThe paradigm

When you need to create a user

interface for XML data, use XForms.

Page 6: SLIDES

66© Copyright 2008 IBM Corporation.

Our Sample Application: Our Sample Application: Bracketology Bracketology

Page 7: SLIDES

7© Copyright 2008 IBM Corporation.

BracketologyBracketology

• Our XML document represents a sixteen-team, single-elimination tournament.

• We’ll choose between competitors until only one is left.

• We’ll use XForms to display the competitors, update the XML data and generate the matchups for the later rounds of the tournament.

Page 8: SLIDES

8© Copyright 2008 IBM Corporation.

The XML document structureThe XML document structure

<bracket>

<title>The Santa Clara Smackdown</title>

<contestants>

<contestant> <!-- 16 contestants -->

</contestants>

. . .

<results>

<result> <!-- 15 results -->

</results>

</bracket>

Page 9: SLIDES

9© Copyright 2008 IBM Corporation.

A contestantA contestant

<contestant

seed="1"

image="images/sca-sdo.jpg">

SCA-SDO

</contestant>• The seed determines the matchups in the first

round. • The image attribute is used as a URL.• The text of the element is what appears in the

bracket.

Page 10: SLIDES

10© Copyright 2008 IBM Corporation.

A resultA result

<result

round="1"

firstSeed="1"

secondSeed="16"

winnerSeed="1"/>• The round attribute indicates in which of the

four rounds this result occurred. • The firstSeed and secondSeed attributes

indicate which contestants faced each other. • The winnerSeed attribute indicates who won.

They move on to the next round.

Page 11: SLIDES

11© Copyright 2008 IBM Corporation.

ComplicationsComplications

• The seedings of the contestants determine the matchups for the first round.

• We don’t know who’s involved in the second round until the first round is completed.

• It’s confusing. For example:– The winner of the first matchup in the first round is

the first contestant in the first matchup of the second round.

– The winner of the second matchup in the first round is the second contestant in the first matchup of the second round.

Page 12: SLIDES

12© Copyright 2008 IBM Corporation.

Assembly with SCAAssembly with SCA

<result round="1" firstSeed="1" secondSeed="16" winnerSeed="1"winnerSeed="1"/>

<result round="1" firstSeed="8" secondSeed="9" winnerSeed="9"winnerSeed="9"/>

. . .

<result round="2" firstSeed="1"firstSeed="1" secondSeed="9"secondSeed="9" winnerSeed=""/>

• We can define these relationships in XForms. When we move from one round to the next, we’ll use <xf:setvalue> to update the results correctly.

Page 13: SLIDES

13© Copyright 2008 IBM Corporation.

Choosing between contestantsChoosing between contestants

Page 14: SLIDES

14© Copyright 2008 IBM Corporation.

XHTML page layoutXHTML page layout

Page 15: SLIDES

15© Copyright 2008 IBM Corporation.

The bracket displayThe bracket display

Page 16: SLIDES

1616© Copyright 2008 IBM Corporation.

Demo timeDemo time

Let the games begin!

Page 17: SLIDES

1717© Copyright 2008 IBM Corporation.

SummarySummary

Page 18: SLIDES

18© Copyright 2008 IBM Corporation.

SummarySummary

• We’ve used an XForms document to display and manipulate a complicated XML document format.

• All of the data manipulation is done in XForms, yet we get nice AJAX-like effects as we move between rounds, panels, etc.

• The result is a sophisticated interface that is built around our XML document type, generates valid XML data and is easily maintained.

Page 19: SLIDES

19© Copyright 2008 IBM Corporation.

Bracketology articles at Bracketology articles at developerdeveloperWorksWorks

• Using XSLT to generate the bracket from the XML:– Uses new features from XSLT 2.0/XPath 2.0:

The to operator, sequences and <xsl:function>– ibm.com/developerworks/xml/library/ x-xslt20xpath20/

• Use an XForms document as a custom XML editor:– Covers the entire XForms document we’ve

demonstrated here– Uses XSLT 2.0 to refactor the XForms code, leaving a

70% smaller document to maintain– ibm.com/developerworks/library/x-xformsxslt/

Host your own

Host your own

tournament!

tournament!

Page 20: SLIDES

20© Copyright 2008 IBM Corporation.

One more timeOne more time

When you need to create a user

interface for XML data, use XForms.

Page 21: SLIDES

21© Copyright 2008 IBM Corporation.

oasis-opencsa.org/sca-roadshow/oasis-opencsa.org/sca-roadshow/

Page 22: SLIDES

2222© Copyright 2008 IBM Corporation.

Thanks!Thanks!

Doug Tidwell, [email protected]