The original Powerpoint Slides - Karl Wilcox

chunkyscreechΔιακομιστές

4 Δεκ 2013 (πριν από 3 χρόνια και 8 μήνες)

86 εμφανίσεις

TUTORIAL

STARTS

7PM

“PATIENCE, LEARN YOU MUST”

1

START RECORDING!


Recordings in various formats will be available in a few
days


Check out the Tutor Group Forums for:


Recording links


Copies of slides


Any follow questions and answers



Please use the “chat” box to chat!


Bad enough listening to me for 90 minutes


At least you can chat to the other students


Any subject you like, I will ignore box except for questions!

2

T320

TUTORIAL

TWO

PROTOCOLS, XML & TMA02

3

PROPOSED AGENDA


Where are we?


Eclipse


Protocols


XML


Data


Metadata


Tools


Schema Design


TMA Tips, Q & A

4

Any questions,
please click the
“raise your hand”
icon

Then type
question in chat
box

Or use
microphone!

PROPOSED UN
-
AGENDA(?)


Security


This is well covered (for our purposes) in Block 2 Part 2


But be aware that this is a BIG subject


You are NOT an expert just having read Part 2!


Message Transport over HTTP


Also well covered, Block 2 part 3


But the protocol stuff here will be useful


The practical work


Thoroughly described in Block 2 parts 4
-
7


Excellent support from the appropriate national forums

5

WHERE ARE
WE?

“IF THERE'S A BRIGHT
CENTER

TO THE
UNIVERSE, YOU'RE ON THE PLANET THAT IT'S
FARTHEST FROM.”

6

OVERVIEW


7

Block 1


E
-
Business in context

Block 2


Protocols and Data

Block 3


Web Services

Block 4


Business Processes

TMA01

TMA02

TMA03

E

M

A


pt

2

EMA
pt

1

You

Are

Here

BLOCK 2

You need to read (and understand!) most of block 2 material
before

starting TMA02

You have 2 ½ weeks remaining

Do not panic!

If really pushed for time, Block 2 Part 3 is not immediately
relevant to the TMA


But you will struggle with Block 3 without it


Contact your tutor if you have any questions or problems

(More on the TMA later…)

8

ECLIPSE

“THAT’S NO MOON! THAT’S A SPACE STATION”

9

ECLIPSE TIPS


Don’t Panic!



Watch the video for an overview


From the T320 website


Or on the DVD



Watch the 2
nd

recording in the Module
-
Wide tutorial room


Introduction to Eclipse, XML and XML schema (Pat and
Mike) ~ 1hr 12mins

10

ECLIPSE LAYOUT

11

MY VIEW OF ECLIPSE

(YMMV)


For any given task, there is probably something better
than Eclipse


PHP editing


PHPStorm


XML Editing


Oxygen


But for integration,
flexibilty

and add
-
ons (of all types)
there is little to beat it


Especially for large teams


As a developer, do I use it by choice?


Yes, but due to Inertia! First large scale IDE I used


Gradually migrating to something less “heavy”


And less “austere” (more colourful and fun!)

12

PROTOCOLS

“I AM C
-
3PO, HUMAN
-
CYBORG RELATIONS...”

“DON’T NEED A PROTOCOL DROID…”

13

BLOCK 2 PART 1


Good, interesting material


And quite brief!


Don’t worry too much about EDI / EDIFACT


For historical interest only


Make sure you understand:


Structured and unstructured data


What a protocol is (next slide)

14

WHAT IS A PROTOCOL?

1
-

The pattern of message exchange


How is an interaction started? Who can start it?


How do we take turns? Synchronous or asynchronous?


What is the procedure for handling errors?


How to manage acknowledgements?


How to end / complete the interaction



Interesting aside…


If we expect the other guy to acknowledge our message
was received, should we acknowledge their
acknowledgement?



15

WHAT IS A PROTOCOL?

1
-

The pattern of message exchange


How is an interaction started? Who can start it?


How do we take turns? Synchronous or asynchronous?


What is the procedure for handling errors?


How to manage acknowledgements?


How to end / complete the interaction



Interesting aside…


If we expect the other guy to acknowledge our message was
received, should we acknowledge their acknowledgement?



Look up “The Two Generals’ Problem” on Wikipedia


16

WHAT IS A PROTOCOL?

2


The format and semantics of messages


The arrangement of data


Where stuff starts and ends


What format the data is in


The difference between “protocol data” and “payload data”


What does the data
mean
?


Especially the “protocol data” e.g. flags, lengths,
checksums


The “payload data”
may

just be “data” (i.e. treated as a
single “chunk” of bytes


17

EXAMPLE
PROTOCOLS

“Good Evening”

“Table for four
please”

“This way please”

“Thank you”

“Here are your
menus, would you
like to order your
drinks now?”

GET /t320/
index.cfm

HTTP/1.1

Host
:
dell400.open.ac.uk



HTTP/1.1 200 OK

Server
: Microsoft
-
IIS/4.0

Date
: Mon, 01 Jul 2002
13:38:27 GMT

Content
-
Length
2722


18

LAYERED
PROTOCOLS

Block 2 Part 3


Message
Exchange over HTTP

Important to understand
“Layered Protocols”

19

XML

“WHAT’S IN THERE?”

“ONLY WHAT YOU TAKE WITH YOU…”

20

XML TERMINOLOGY

<item about=“this”>A string of Characters</item>

21

Attribute

Name Value

Start Tag

End Tag

Element

Content

Element

XML DATA

Can be in the content…


<h1>My Webpage</h1


Can be in an attribute value…


<
img

src
=“http://xkcd.org/1011.jpg”/>


Can be the presence of the element itself…


<
hr

/>

22

METADATA

It is a useful distinction to talk about “data” and “metadata”

“Metadata” is “data about the data”


It is NOT the data itself, but is additional information that
helps interpret or categorise the data


Could also consider it “primary” vs. “secondary” data


<fuel
-
load units=“litres”>10000</fuel
-
load>


Or the MP3 “tags” that provide artist, album, & genre details

23

CREATING XML


By hand, in an editor


Not typical, except authoring of structured documents


Where there is much more content than structure


E.g. Oxygen XML/Author to create product manual


Programmatically (i.e. through a computer program)


By writing out XML as a text file


Need to know ALL the data beforehand


(Except in very trivial cases, like log files)


Need to know ALL the structure beforehand


Or use a DOM Interface…

24

CREATING XML THROUGH
A
DOM

INTERFACE


Remember, XML has a hierarchical (tree like) structure


So we can create that tree by adding “branches” as
required, where required (and then move them around!)


A typical DOM interface has functions like:


Document.CreateElement
(
ElementName
)


Element.AddAttribute
(
Name,Value
)


Element.AddChild
(Element) /
Element.RemoveChild
()


Element.AddContent
(
CharacterData
)


When complete, write out as an XML file


Document.CreateXMLFile
(
RootElement
)

25

XML HIERARCHY

26

READING XML
-

DOM


We can also use a DOM interface to read XML


Typical functions include:


Document.ReadXMLFile
(Filename)


Element.GetAttribute
(Name)


Element.GetContent
()


Element.GetChildren
()


In this way data can be read and used in a program


Points to note:


ALL the data is read in by the program


“Navigation” can be long
-
winded for “deep” trees

27

READING XML


SAX


An alternative approach is to use a SAX interface


XML is read element
-
by
-
element


You tell the interface which elements you want to work on


Typical interface might be:


Create a “call back” table
of elements and
function calls


(i.e. call function X when you find element E)


ParseFile
(Filename,
CallBackTable
)



How do you specify the elements you need? X
-
PATH


28

X
-
PATH

Examples:


/contact/name/
familyname


//town


Others:


//Element[name=“value”]


These can get really long and complicated! (Debug tools available)


29

CONVERTING XML


What if want to reorganise XML to match another schema?


We already know one way:


Use DOM to read in “old” XML, rearrange as required,
write out “new” XML


But this requires a program to be written


Alternative is an XSLT processor


Takes an existing XML file, and a specification of changes


Creates new XML file based on:


An specification of an element pattern (X
-
PATH!)


Some instructions as to what to output


All these instructions are written in XML!


But can be tricky


need to understand recursion…

30

XSLT PROCESSOR

31

Input

XML

File

Transform

Specification

(XML)

Output

XML

File

XSLT

Processor

(application)

RESTRICTING XML


With XML we can define elements and attributes at whim


It is useful to restrict XML to a specific “vocabulary”


So we can define it, share it, re
-
use it


Originally


Document Type Definitions ( DTD )


Kinda

weird syntax


don’t worry about this


But note that XHTML is still defined by a DTD


Newer approach XML
-
SCHEMA


Uses XML to define other elements, attributes


How they can be arranged


What they can contain (e.g. facets)

32

XML SCHEMAS


Best developed using a graphical tool


E.g. Eclipse


But there are better (paid for) tools



Other tools
may

validate XML against a schema


E.g. DOM Interface usually has option to validate


Document.ReadXMLFile
(
FileName,Validate
=true)



If you know (and trust) the source it may not always be
necessary to validate files (does take time & resources)

33

SCHEMA DESIGN


Karl’s Tips for Real Life Schema Design


(Not really necessary for the TMA


i.e. no extra marks!)


Always include schema version no. in your XML


Helps to maintain backwards compatibility


Use element
content
for
data
,
attributes

for
metadata


Makes difference clearer, easier to set defaults


Look for opportunities to re
-
use elements & data


But be aware cannot enforce internal consistency in
schema (e.g. unique IDs, cross
-
references etc.)


Be careful placing mandatory elements (ideally, first)


Helps with forward compatibility (new elements)

34

TMA02 TIPS
Q & A

"YOU'RE IN A DESERT, WALKING ALONG IN THE
SAND, WHEN ALL OF A SUDDEN
..."

"IS THIS THE TEST NOW?"

35

TMA02 Q1


Based on example data gathering form, develop a schema
and example XML data file


You are developing a data representation NOT trying to
reproduce the form


The form is provided as an example of how the data is
gathered at present


Remember, we want a format in which data can be used in
for automation

36

EXAMPLE OF USE

37

XML

Document

Computer

Program

Possible

Sources:


Typed by

a person



Created

in another

program

Database

Possible

Destinations:


Other

programs


Printouts


Different

XML file

Possible

Actions:


Use for database

lookup


Combine with other data


Store in a database

THE “RIGHT” ANSWER?


There isn’t one!


There is a wide range of answers because:


XML can be used in various ways


Elements vs. Attributes


Element organisation / hierarchy / optionality


Element & attribute naming


Strictness vs. flexibility


Hence Q1(c)


Explain, in your terms, why you made particular choices


Any, sensible justification is fine!

38

TMA02 Q2


(a) Tests your understanding of namespaces


Well covered in the course material


(b) Comparing various XML tools in a specific scenario


Some in course material, but also this presentation


(c) Industry Standards
vs

bespoke development


Standards were covered in Block 1


Think about pros and cons


(d) Short report on using image metadata


See this presentation about “metadata”


Don’t worry about references

39

TMA02 TIPS


There are no tricks or traps!


So don’t look for them…


Largely straight forward


But don’t leave it too late to start…


No word count limits


But longer is not always better!


Look at the marks breakdown


Use this to guide your time

40

ANY QUESTIONS?

Please type below or in the chat box

Click on the “Raise your hand” icon to use your microphone

41

WHAT
NEXT?


DIFFICULT TO SEE, ALWAYS IN MOTION IS THE
FUTURE”

42

THANK YOU FOR
WATCHING!


TMA02 Submission date 2
nd

May


Block 3 Material available 16
th

April


Any questions or problems email
k.r.wilcox@open.ac.uk



Check the Tutor Group Forum for slides & recordings



Next tutorial: 28
th

May


43