copyright © 2002 sean c. sullivan xml case study: syncml sean c. sullivan at

31
Copyright © 2002 Sean C. Sullivan XML case study: XML case study: SyncML SyncML Sean C. Sullivan <sean> at <seansullivan> <.com>

Post on 21-Dec-2015

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

XML case study: XML case study: SyncMLSyncML

Sean C. Sullivan

<sean> at <seansullivan> <.com>

Page 2: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

Agenda

XML and SyncML Sync4j project Q & A

Page 3: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

XML basics

“well-formed” documents DTD

– Document Type Definition “valid” documents

Page 4: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

Simple XML document

<?xml version="1.0"?><!DOCTYPE Weather SYSTEM “weather.dtd”><Weather><Forecast><City>Portland, Oregon</City><Description>Rainy</Description><Temperature>47</Temperature></Forecast></Weather>

Page 5: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

How are XML and SyncML related?

XML is a language for defining application-specific markup languages

SyncML is an XML-based markup language

Page 6: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

Simple SyncML document<SyncML><SyncHdr><VerDTD>1.0</VerDTD><VerProto>SyncML/1.0</VerProto>…</SyncHdr><SyncBody><Add>…</Add></SyncBody></SyncML>

Page 7: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

SyncML defined…“SyncML is a new industry initiative to develop and

promote a single, common data synchronization protocol that can be used industry-wide.” (syncml.org)

“SyncML is a specification for a common data synchronization framework and XML-based format […] for synchronizing data on networked devices.” (syncml.org)

“SyncML is a […] protocol for conveying data synchronization operations.” (syncml.org)

Page 8: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

SyncML sponsors

Page 9: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

What is data synchronization?

Data synchronization “is the process of making two sets of data look identical” (syncml.org whitepaper)

Page 10: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

Data Synchronization

Resolve conflicts

Datastore1

Exchange data modifications

Datastore2

A CB C A BA CB

Page 11: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

What is a “data synchronization protocol”?

Method of communication for a data synchronization session

Protocol includes:– naming and identification of records– common protocol commands– identification and resolution of

synchronization conflicts

Page 12: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

SyncML features

Synchronize any type of data Multiple transport protocol bindings

– HTTP, WSP, OBEX Security Interoperability

Page 13: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

SyncML: clients & servers

SyncMLserver

server modifications

client modifications

Page 14: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

SyncML & XML

Abbreviated naming convention– Ex: ”protocol version” is <VerProto>

XML prolog is not required WBXML

– WAP Binary XML

Page 15: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

SyncML documents

<SyncML> DTD Meta info DTD Device info DTD

Page 16: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

<SyncML> document<?xml version="1.0"?><!DOCTYPE … ><SyncML><SyncHdr>…</SyncHdr><SyncBody><Add>…</Add></SyncBody></SyncML>

“A SyncML Message is a well-formed, but not necessarily valid, XML document.” (syncml.org)

Contains data synchronization commands (operations)

Page 17: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

<SyncHdr> element<SyncHdr>

<VerDTD>1.0</VerDTD>

<VerProto>SyncML/1.0</VerProto>

<SessionID>session41</SessionID>

<MsgID>msg80386</MsgID>

</SyncHdr>

Page 18: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

<SyncBody> element<SyncBody>

<Add>

<CmdID>cmd80486</CmdID>

<Item>…</Item>

</Add>

</SyncBody>

Page 19: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

SyncML commands <Add> <Alert> <Atomic> <Copy> <Delete> <Exec> <Get> <Map>

<Put> <Replace> <Results> <Search> <Sequence> <Status> <Sync>

Page 20: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

Meta Info document

Contains sync session parameters

<MetInf><Format>…</Format><Type>…</Type>…<MaxMsgSize>586</MaxMsgSize>…</MetInf>

Page 21: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

Device Info document

Describes device capabilities

For both client and server

<DevInf>

<SwV>0.99</SwV>

<HwV>3.14</HwV>

<DevTyp>pda</DevTyp>

</DevInf>

Page 22: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

Sync4j project

Java implementation of SyncML protocol

sync4j client & sync4j server open source http://sync4j.sourceforge.net/

Page 23: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

XML parsing SAX

– “Simple API for XML” DOM

– document object model

Page 24: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

Choosing an XML parser support for SAX 1.0? SAX 2.0? support for DOM? support for XML Namespaces? validating or non-validating parser? validation with DTD’s? validation with XML Schema?

Page 25: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

XML parsers for Java Apache Xerces-J Apache Crimson Sun JAXP

– “Java API for XML Parsing” JDOM Also:

– DOM4J, Oracle XML Parser for Java, ElectricXML, kxml, …

Page 26: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

sync4j key classes

Message DeviceInfo MetaInfo Command classes:

– AddCommand– DeleteCommand– ReplaceCommand

Page 27: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

Sync4j Message example 1String strXML = “<SyncML> … </SyncML>”;Message msg;try{ msg = new Message(strXML);}catch (InvalidMarkupException ex){}catch (XMLSyntaxException ex){}

Page 28: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

Sync4j Message example 2SyncHeader header = new SyncHeader(...);SyncBody body = new SyncBody(...);Message msg;msg = new Message(header, body);String strXML = msg.toXML();

Page 29: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

XML data binding tools

Castor– http://www.castor.org/

Zeus– http://zeus.enhydra.org/

Sun JAXB– http://java.sun.com/xml/

Page 30: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

Summary SyncML is an XML-based data

synchronization protocol Choose your XML parser carefully Consider using an XML data-binding

tool http://www.syncml.org/ http://sync4j.sourceforge.net/

Page 31: Copyright © 2002 Sean C. Sullivan XML case study: SyncML Sean C. Sullivan at

Copyright © 2002 Sean C. Sullivan

XML case study: XML case study: SyncMLSyncML

Sean C. Sullivan

<sean> at <seansullivan> <.com>