1 / 31

XML case study: SyncML

XML case study: SyncML. Sean C. Sullivan <sean> at <seansullivan> <.com>. Agenda. XML and SyncML Sync4j project Q & A. XML basics. “well-formed” documents DTD D ocument T ype D efinition “valid” documents. Simple XML document. <?xml version="1.0"?>

breck
Télécharger la présentation

XML case study: SyncML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XML case study: SyncML Sean C. Sullivan <sean> at <seansullivan> <.com>

  2. Agenda • XML and SyncML • Sync4j project • Q & A

  3. XML basics • “well-formed” documents • DTD • Document Type Definition • “valid” documents

  4. 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>

  5. How are XML and SyncML related? • XML is a language for defining application-specific markup languages • SyncML is an XML-based markup language

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

  7. 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)

  8. SyncML sponsors

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

  10. Datastore1 A B C • Exchange data modifications A B C A B C Data Synchronization Datastore2 • Resolve conflicts

  11. 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

  12. SyncML features • Synchronize any type of data • Multiple transport protocol bindings • HTTP, WSP, OBEX • Security • Interoperability

  13. server modifications client modifications SyncML: clients & servers SyncML server

  14. SyncML & XML • Abbreviated naming convention • Ex: ”protocol version” is <VerProto> • XML prolog is not required • WBXML • WAPBinary XML

  15. SyncML documents • <SyncML> DTD • Meta info DTD • Device info DTD

  16. <?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) <SyncML> document

  17. <SyncHdr> element <SyncHdr> <VerDTD>1.0</VerDTD> <VerProto>SyncML/1.0</VerProto> <SessionID>session41</SessionID> <MsgID>msg80386</MsgID> … </SyncHdr>

  18. <SyncBody> element <SyncBody> <Add> <CmdID>cmd80486</CmdID> … <Item>…</Item> </Add> </SyncBody>

  19. SyncML commands • <Put> • <Replace> • <Results> • <Search> • <Sequence> • <Status> • <Sync> • <Add> • <Alert> • <Atomic> • <Copy> • <Delete> • <Exec> • <Get> • <Map>

  20. Contains sync session parameters <MetInf> <Format>…</Format> <Type>…</Type> … <MaxMsgSize>586 </MaxMsgSize> … </MetInf> Meta Info document

  21. Describes device capabilities For both client and server <DevInf> … <SwV>0.99</SwV> <HwV>3.14</HwV> … <DevTyp>pda</DevTyp> … </DevInf> Device Info document

  22. Sync4j project • Java implementation of SyncML protocol • sync4j client & sync4j server • open source • http://sync4j.sourceforge.net/

  23. XML parsing • SAX • “Simple API for XML” • DOM • document object model

  24. 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?

  25. 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, …

  26. sync4j key classes • Message • DeviceInfo • MetaInfo • Command classes: • AddCommand • DeleteCommand • ReplaceCommand

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

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

  29. XML data binding tools • Castor • http://www.castor.org/ • Zeus • http://zeus.enhydra.org/ • Sun JAXB • http://java.sun.com/xml/

  30. 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/

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

More Related