1 / 62

DEV-13: XML Schema to the Rescue

DEV-13: XML Schema to the Rescue. Michael Resnick Principal Software Engineer. Under Development. D I S C L A I M E R. D I S C L A I M E R. This talk includes information about potential future products and/or product enhancements.

sheila
Download Presentation

DEV-13: XML Schema to the Rescue

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. DEV-13:XML Schema to the Rescue Michael Resnick Principal Software Engineer

  2. Under Development D I S C L A I M E R D I S C L A I M E R • This talk includes information about potential future products and/or product enhancements. • What I am going to say reflects our current thinking, but the information contained herein is preliminary and subject to change. Any future products we ultimately deliver may be materially different from what is described here. DEV-13: XML Schema to the Rescue

  3. Agenda • Introduction • Use in the 4GL • Namespaces • Simple Data Types • Complex Data Types • XML Constructs • Extensibility • Demonstration DEV-13: XML Schema to the Rescue

  4. What Is XML Schema? • An XML syntax • Describes structure of an XML document • Describes data types • Similar to OpenEdge™ table schema DEV-13: XML Schema to the Rescue

  5. XML Schema Example - Schema XML Schema Fragment <schema> <element name=“name”> <complexType> <sequence> <element name=“first” type=“string”/> <element name=“last” type=“string”/> </sequence> </complexType> </element> </schema> DEV-13: XML Schema to the Rescue

  6. XML Schema Example - Instance XML Instance <name> <first>Alfred</first> <last>Newman</last> </name> DEV-13: XML Schema to the Rescue

  7. XML Schema – Why? • Validation • Improvement over document type definitions (DTDs) • Concise reference for XML vocabulary • XML becoming ubiquitous • Storage format • Messaging format DEV-13: XML Schema to the Rescue

  8. Existing XML Schemas • Vertical markets standards • MISMO – mortgages • HIPAA – medical • Horizontal market standards • ebXML (e-business exchange) • WS-Security • Others • Commonwealth of Massachusetts DEV-13: XML Schema to the Rescue

  9. Using an XML Schema to Validate XML Schema Document XML Document (refers to X.xsd) Validating Parser X.xml X.xsd Validated XML Document DEV-13: XML Schema to the Rescue

  10. XML Schema Compared to DTD • Richer set of data types • More detail about data type • Is an XML syntax • Extensible DEV-13: XML Schema to the Rescue

  11. XML Schema 1.0 Specifications • W3C Recommendation: 2001 • Second edition: 2004 DEV-13: XML Schema to the Rescue

  12. XML Schema Specifications - New • XML Schema 1.1: 24 February 2005 (Working Draft) • Simplification • Namespace versioning • Corrections • Minor data type extensions • Schema Component Designators:29 March 2005 (Last Call Working Draft) DEV-13: XML Schema to the Rescue

  13. XML Schema – What does it do? • Defines structured documents • Progress Tables • Relational Database table • Programming language structures • Defines semi-structured documents • XHTML • DocBook • SOAP • Defines an XML namespace DEV-13: XML Schema to the Rescue

  14. Agenda • Introduction • Use in the 4GL • Namespaces • Simple Data Types • Complex Data Types • XML Constructs • Extensibility • Demonstration DEV-13: XML Schema to the Rescue

  15. Use in the 4GL • Currently • 4GL web service provider • 4GL web service client • Release 10.1A • DOM API • SAX Reader API • ProDataSet andTEMP-TABLE serialization } SOAP } Explicit (de)serialization } Automatic (de)serialization DEV-13: XML Schema to the Rescue

  16. Agenda • Introduction • Use in the 4GL • Namespaces • Simple Data Types • Complex Data Types • XML Constructs • Extensibility • Demonstration DEV-13: XML Schema to the Rescue

  17. XML Namespaces • Mix different XML vocabularies <bib:book xmlns:bib=“urn:biblio” xmlns:pn=“http://schemas/personalName”> <bib:title>Madmiration</bib:title> <bib:author> <pn:name> <pn:title>Dr.</pn:title> <pn:first>Alfred</pn:first> <pn:middleInit>E</pn:middleInit> <pn:last>Newman</pn:last> </pn:name> </bib:author> </bib:book> DEV-13: XML Schema to the Rescue

  18. Namespaces • Elements known by two values:Namespace (URI) Local nameurn:biblio titlehttp://schemas/personalName title • Prefix is an artifact of serializationbib pn • Prefix associated with namespace using xmlns:prefix=“namespace-uri” construct DEV-13: XML Schema to the Rescue

  19. Default Namespace • Allows for elements without a prefix to be part of a namespace. <title xmlns=“urn:biblio”>…</title> DEV-13: XML Schema to the Rescue

  20. No Namespace • Use no namespace declarations. <title>…</title> DEV-13: XML Schema to the Rescue

  21. Namespace Prefix Scope Namespace is visible for all elements appearing within its declaration <ns:book xmlns:ns=“urn:biblio”> <ns:title>...</ns:title> <ns:author> <ns:name xmlns:ns=“http://schemas/personName”> <ns:title>...</ns:title> ... </ns:name> </ns:author> </ns:book> DEV-13: XML Schema to the Rescue

  22. Agenda • Introduction • Use in the 4GL • Namespaces • Simple Data Types • Complex Data Types • XML Constructs • Extensibility • Demonstration DEV-13: XML Schema to the Rescue

  23. Simple Data Types • The string of characters within an element or an attribute value<anElement anAttribute=“simple-type”>simple-type</anElement> • Definition specifies • string representations: “0001234”, “+1234” • limitations (facets) on value:0 < x < 10, password 6-10 characters long DEV-13: XML Schema to the Rescue

  24. Simple Data Types anyType 40+ simple types anySimpleType all complex types dateTime decimal string integer long DEV-13: XML Schema to the Rescue

  25. Agenda • Introduction • Use in the 4GL • Namespaces • Simple Data Types • Complex Data Types • XML Constructs • Extensibility • Demonstration DEV-13: XML Schema to the Rescue

  26. Complex Data Types - Structures • A construct of simple types • sequence (data structure) • choice (union) • all (order unimportant) <name> <first></first> <middle></middle> <last></last></name> name last middle first DEV-13: XML Schema to the Rescue

  27. Complex Data Types - Content • Content can be • elements • attributes • mixed (elements and text à la XHTML) DEV-13: XML Schema to the Rescue

  28. Complex Data - Model Element Text Attribute DEV-13: XML Schema to the Rescue

  29. Agenda • Introduction • Use in the 4GL • Namespaces • Simple Data Types • Complex Data Types • XML Constructs • Attributes • Elements • Groups • Keys, Keyrefs and Unique • Extensibility • Demonstration DEV-13: XML Schema to the Rescue

  30. Attributes • Always defined by simple type • Specify use: optional, required or fixed • Specify default value XML Schema Fragment <attribute name=“count” type=“integer” default=“1” use=“optional”/> XML Instance <elementcount=“5”>content</element> DEV-13: XML Schema to the Rescue

  31. Elements • Define by a type (simple or complex) • Expresses parent/child relationship • May have attributes DEV-13: XML Schema to the Rescue

  32. Elements • Can specify extent (minOccurs/maxOccurs) • Mandatory singleton minOccurs=1 maxOccurs=1 • Optional singleton minOccurs=0 maxOccurs=1 • Fixed length array minOccurs=n maxOccurs=n • Variable length array minOccurs=m maxOccurs=n • Nilability (true/false) ≈ UNKNOWN allowed? DEV-13: XML Schema to the Rescue

  33. Defining an Element XML Schema Fragment <element name=“lineItem” type=“string” minOccurs=“1” maxOccurs=“unbounded” nillable=“false”><attribute name=“lineNumber” type=“int”/> </element> XML Instance <lineItem lineNumber=“1”>widget</lineItem> <lineItem lineNumber=“15”>gadget</lineItem> DEV-13: XML Schema to the Rescue

  34. Groups (Element) andAttributeGroups • Reusable “macros” • Inline inclusion of elements/attributes DEV-13: XML Schema to the Rescue

  35. Group Example:Definition and Reference XML Schema Fragment <group name=“names”> <sequence> <element name=“firstName” type=“string”/> <element name=“lastName” type=“string”/> </sequence> </group> <element name=“name”> <sequence> <element name=“title” type=“string”/> <group ref=“names”/> </seqeuence> </element> DEV-13: XML Schema to the Rescue

  36. Group Instance XML Instance <name> <title>Mr.</title> <firstName>Alfred</firstName> <lastName>Newman</lastName> </name> DEV-13: XML Schema to the Rescue

  37. Unique • Unique • element or attribute values in a sequence must be unique <recordlist> <record><id>1</id><name>foo</name></record> <record><id>2</id><name>bar</name></record> <record><id>3</id><name>baz</name></record> </recordlist> DEV-13: XML Schema to the Rescue

  38. Keys and Keyrefs • Keys – Same as Unique plus: • Must not be nil • Can be referenced by keyref • Similar to XML id attributes • Keyrefs • Defines a relationship between two constructs (attributes or elements) • Similar to HTML href attribute DEV-13: XML Schema to the Rescue

  39. Keys and Keyrefs - Model Element Text Attribute Keyref DEV-13: XML Schema to the Rescue

  40. Agenda • Introduction • Use in the 4GL • Namespaces • Simple Data Types • Complex Data Types • XML Constructs • Extensibility • Data types • Language • Demonstration DEV-13: XML Schema to the Rescue

  41. Extensibility:Simple Type Derivation by Restriction integer …0123 -(264) <= n <= 264 - 1 long decimal ...0123[.4560…] DEV-13: XML Schema to the Rescue

  42. Extensibility:Complex Type Derivation by Extension DEV-13: XML Schema to the Rescue

  43. Extensibility:Complex Type Derivation by Restriction DEV-13: XML Schema to the Rescue

  44. Extensibility: XML Schema Language • Can add your own XML Schema • elements • attributes • annotations • Useful for • storing and retrieving extra information • sending extra information DEV-13: XML Schema to the Rescue

  45. Extensibility: Schema Language Modularity • Import – Combine schema definitions • Include – Organize complex definition Import Include DEV-13: XML Schema to the Rescue

  46. Agenda • Introduction • Use in the 4GL • Namespaces • Simple Data Types • Complex Data Types • XML Constructs • Extensibility • Demonstration DEV-13: XML Schema to the Rescue

  47. New Schema Document DEV-13: XML Schema to the Rescue

  48. Complex name Element DEV-13: XML Schema to the Rescue

  49. Fully Define Complex name Element DEV-13: XML Schema to the Rescue

  50. SingleChar Type Definition DEV-13: XML Schema to the Rescue

More Related