XML, JSON and OpenEdge Robin Brown

Slides:



Advertisements
Similar presentations
Server Access The REST of the Story David Cleary
Advertisements

Chapter 10: Designing Databases
XML: text format Dr Andy Evans. Text-based data formats As data space has become cheaper, people have moved away from binary data formats. Text easier.
XML & Data Structures for the Internet Yingcai Xiao.
An Introduction to XML Based on the W3C XML Recommendations.
Improving your OpenEdge® Development Productivity David Lund Sr. Training Program Manager, Progress.
Scale Up Access to your 4GL Application using Web Services
XML DOM and SAX Parsers By Omar RABI. Introduction to parsers  The word parser comes from compilers  In a compiler, a parser is the module that reads.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
Peoplesoft: Building and Consuming Web Services
Introduction to XML Extensible Markup Language
Performance testing of Progress Appservers and a plug-in for Jmeter
Introducing HTML & XHTML:. Goals  Understand hyperlinking  Understand how tags are formed and used.  Understand HTML as a markup language  Understand.
PHP and XML TP2653 Advance Web Programming. PHP and XML PHP5 – XML-based extensions, library and functionalities (current XAMPP PHP version is )
Chapter 12 Creating and Using XML Documents HTML5 AND CSS Seventh Edition.
Web Development Challenges and How They are Solved in ps:eScript Matt Verrinder Progress Software UK Internet & Integration Technologies.
Networking Nasrullah. Input stream Most clients will use input streams that read data from the file system (FileInputStream), the network (getInputStream()/getInputStream()),
Chapter 9 Web Services Architecture and XML. Objectives By study in the chapter, you will be able to: Describe what is the goal of the Web services architecture.
DEV-07: Increasing Productivity with Tools for Business Logic Gikas Principal Software Engineer.
Avro Apache Course: Distributed class Student ID: AM Name: Azzaya Galbazar
SOA-12: Integrate over the Web with OpenEdge® Web Services
Why XML ? Problems with HTML HTML design - HTML is intended for presentation of information as Web pages. - HTML contains a fixed set of markup tags. This.
CREATED BY ChanoknanChinnanon PanissaraUsanachote
XP New Perspectives on XML, 2 nd Edition Tutorial 10 1 WORKING WITH THE DOCUMENT OBJECT MODEL TUTORIAL 10.
Computers Data Representation Chapter 3, SA. Data Representation and Processing Data and information processors must be able to: Recognize external data.
What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data.
Introduction to XML Extensible Markup Language. What is XML XML stands for eXtensible Markup Language. A markup language is used to provide information.
ARCH-03: Implementing the OpenEdge™ Reference Architecture – Part 1 John Sadd Progress Fellow and OpenEdge Evangelist.
Chapter 8 Cookies And Security JavaScript, Third Edition.
DEV-5: Introduction to WebSpeed ® Stephen Ferguson Sr. Training Program Manager.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
1 Dr Alexiei Dingli XML Technologies XML Advanced.
DEV-09: User Authentication in an OpenEdge™ 10.1 Distributed Computing Environment Michael Jacobs Development Architect.
INT-5: Integrate over the Web with OpenEdge® Web Services
Introduction to XML This presentation covers introductory features of XML. What XML is and what it is not? What does it do? Put different related technologies.
School of Computing and Information Systems CS 371 Web Application Programming XML and JSON Encoding Data.
Web Services with Apache CXF Part 2: JAXB and WSDL to Java Robert Thornton.
ARCH-07: Implementing the OpenEdge™ Reference Architecture – Part 2
XML and Database.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
DEV-3: Getting Started with OpenEdge® Architect – Part II David Lund Sr. Training Program Manager Mark Hanley Sr. Manager Development Tools.
XML eXtensible Markup Language. XML A method of defining a format for exchanging documents and data. –Allows one to define a dialect of XML –A library.
INT-9: Implementing ESB Processes with OpenEdge ® and Sonic ™ David Cleary Principal Software Engineer.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
 defined as Extensible Markup Language (XML) is a set of rules for encoding documents  Defines structure and data.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
Computing & Information Sciences Kansas State University Friday, 20 Oct 2006CIS 560: Database System Concepts Lecture 24 of 42 Friday, 20 October 2006.
CO1552 – Web Application Development Further JavaScript: Part 1: The Document Object Model Part 2: Functions and Events.
XML CSC1310 Fall HTML (TIM BERNERS-LEE) HyperText Markup Language  HTML (HyperText Markup Language): December  Markup  Markup is a symbol.
ARCH-7: Integrate this! SonicMQ® and the OpenEdge® Reference Architecture Christian Stiller Technical Architect.
Martin Kruliš by Martin Kruliš (v1.1)1.
AJAX. Ajax  $.get  $.post  $.getJSON  $.ajax  json and xml  Looping over data results, success and error callbacks.
Pattern Libraries: Theory Adrian Slade Principal Pattern Engineer
Module 3: Using XML. Overview Retrieving XML by Using FOR XML Shredding XML by Using OPENXML Introducing XQuery Using the xml Data Type.
SEMI-STRUCTURED DATA (XML) 1. SEMI-STRUCTURED DATA ER, Relational, ODL data models are all based on schema Structure of data is rigid and known is advance.
JSON. JSON as an XML Alternative JSON is a light-weight alternative to XML for data- interchange JSON = JavaScript Object Notation It’s really language.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
XML Extensible Markup Language
D Copyright © 2004, Oracle. All rights reserved. Using Oracle XML Developer’s Kit.
XML & JSON. Background XML and JSON are to standard, textual data formats for representing arbitrary data – XML stands for “eXtensible Markup Language”
Introduction to Mongo DB(NO SQL data Base)
392-"JOIN" us on DataServers Journey
DEV-25: You've Got a Problem, Here’s How to Find It
JQUERY Online TRAINING AT GOLOGICA
XML in Web Technologies
Chapter 9 Web Services: JAX-RPC, WSDL, XML Schema, and SOAP
CS 240 – Advanced Programming Concepts
Call Any Web Service from the Progress 4GL
SOA-09: Conducting Business with OpenEdge® and SonicMQ®
Presentation transcript:

XML, JSON and OpenEdge Robin Brown Principal Software Engineer, Progress Software 10-June-2014

Disclaimer This talk includes information about future product enhancements What we are going to say reflects our views on future projects. The information contained herein is preliminary and subject to change. Any future product we ultimately deliver may be materially different from what is described here.

OpenEdge Support for XML/JSON in the ABL XML Sax-Writer Release 10 ProDataSet to/from XML XML Schema Validation ProDataSet to/from JSON Release 11 XML X-Document Version 9 XML Sax-Reader More ProDataSet XML Schema Support JSON OO-ABL API ProDataSet JSON Before-Image We keep making XML and JSON easier to use 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014

Agenda XML in OpenEdge JSON in OpenEdge XML vs. JSON Q & A

Why XML is Important Why XML? Use Cases Industry standard format for document/data exchange Use Cases Sending structured data over the Internet Back bone of Web Services/SOAP Sharing data with 3rd party applications Crystal Reports Persistent storage between ABL sessions Context Management

Document Object Model (DOM) DOM and SAX – V9 Document Object Model (DOM) W3C standard DOM Tree in Memory Application logic - Tree traversal & tree building Simple API for XML (SAX) De facto standard Stream – forward only Application logic – Callbacks Sax-Writer 10.1A CREATE X-DOCUMENT hDoc. hDoc:LOAD("file", “Music.xml", FALSE). CREATE SAX-READER hSax. hSax:SET-INPUT-SOURCE(“file", "Music.xml"). RUN Handler.p Persistent SET h. hSax:HANDLER = h. hSax:PARSE().

SAX-WRITER - STRICT ATTRIBUTE - 10.1A Forces well-formed XML CREATE SAX-WRITER SET-OUTPUT-DESTINATION START-DOCUMENT START-ELEMENT INSERT-ATTRIBUTE WRITE-DATA-ELEMENT END-ELEMENT WRITE-CHARACTERS END-DOCUMENT

DOM/SAX XML Schema Validation – 10.1A CREATE X-DOCUMENT hDoc. hDoc:ADD-SCHEMA-LOCATION ("urn:music", "Music.xsd"). hDoc:LOAD("file", "Music.xml", TRUE /* validate */). CREATE SAX-READER hSax. hSax:SET-INPUT-SOURCE (“file”, “Music.xml”). hSax:SCHEMA-LOCATION = “urn:music Music.xsd”. hSax:VALIDATION-ENABLED = TRUE. /* validate */ hSax:PARSE( ).

DOM vs. SAX Advantages Disadvantages DOM SAX In-place updates All data always available In-place updates Memory Intensive - Cannot handle large docs SAX Much less memory than DOM Can stop the parse early Can access data from a “bad” document (Partial Load) Forward Only Requires Context Management - Callbacks / global variables

ProDataSet/Temp-Table to/from XML – 10.1A WRITE-XML WRITE-XMLSCHEMA READ-XML READ-XMLSCHEMA ttOrder ttItem ttOline Methods apply to ProDataSet Temp-Table Temp-Table Buffer .xsd .xsd .xml .xml

WRITE-XML ( ) / WRITE-XMLSCHEMA – 10.1A Syntax WRITE-XML (target-type, {file | stream | memptr | handle | longchar} [,formatted [,encoding [,schema-location [,write-schema [,min-schema [,write-before-image [,omit-initial-values]]]]]]) WRITE-XMLSCHEMA (target-type, {file | stream | memptr | handle | longchar} [,formatted [,encoding [,min-schema [,omit-initial-values]]]]) *omit-initial-values added in 10.2A

Gives you Control over XML format XML Attributes Gives you Control over XML format Attribute Applies to... NAMESPACE-URI / NAMESPACE-PREFIX ProDataSet, Temp-Table and Buffer XML-NODE-TYPE Buffer-Field XML-DATA-TYPE NESTED Data-Relation XML-NODE-NAME (10.1C) FOREIGN-KEY-HIDDEN (10.2A) SERIALIZE-NAME (10.2B) SERIALIZE-HIDDEN (10.2B)

Nested/Foreign-Key-Hidden - Data-Relation DATASET CustOrder:GET-RELATION(“custOrd”):NESTED = TRUE. DATASET CustOrder:GET-RELATION(“custOrd”):FOREIGN-KEY-HIDDEN = TRUE. CustNum not present with FOREIGN-KEY-HIDDEN

ProDataSet - write-before-image = TRUE After table data Record marked as “modified” Record marked as “created”

ProDataSet – write-before-image = TRUE Before-image of modified record

Progress XML Schema Extensions “prodata” namespace field-level attributes non-unique index definition

READ-XML ( ) / READ-XML-SCHEMA ( ) - 10.1A READ-XML (source-type, {file | memptr | handle | longchar} , read-mode, schema‑location, override-default-mapping [, field-type-mapping [, verify-schema-mode ]]) Recognizes Before-image format – Progress and Microsoft Infers Schema from Data Recognizes non-Progress XML Schema formats Creates a DataSet - when it can! READ-XMLSCHEMA (source-type, {file | memptr | handle | longchar} , override-default-mapping [, field-type-mapping [, verify-schema-mode ]])

xsdto4gl – XSD to 4GL utility XML utilities – 10.1A xsdto4gl – XSD to 4GL utility Produces .i with Dataset definition from XML Schema file wsdldoc – WSDL Analyzer update Produces documentation on Web service operation invocation Converts <complexType> parameters to Datasets when appropriate bproxsdto4gl { xml-schema-file ... } bprowsdldoc { WSDL-URL ... }

Recognize more XML formats as DataSets – 11.0 Benefit Easier integration with 3rd party products PARENT-ID-RELATION Child record has field with RECID of parent PARENT-ID-FIELD PARENT-FIELDS-BEFORE/AFTER Availability: READ-XML/READ-XMLSCHEMA ( ) xsdto4gl utility wsdldoc utility WRITE-XML ( ) does the right thing

Example – PARENT-ID-RELATION <CustomerOrders> <Customer> <CustNum>1</CustNum> <Name>Lift Tours</Name> <Order> <OrdNum>100</OrdNum> <OrdTot>234.89</OrdTot> </Order> </Customer> <CustNum>3</CustNum> <Name>Hoops</Name> <OrdNum>200</OrdNum> <OrdTot>899.99</OrdTot>  </Customer> </CustomerOrders> DEFINE TEMP-TABLE Customer FIELD CustNum AS INTEGER FIELD Name AS CHARACTER. DEFINE TEMP-TABLE Order FIELD OrdNum AS INTEGER FIELD OrdTot AS DECIMAL FIELD Customer_Id AS RECID XML-NODE-TYPE “Hidden”. DEFINE DATASET CustomerOrders FOR Customer, Order PARENT-ID-RELATION rel1 PARENT-ID-FIELD Customer_Id.

Example – PARENT-FIELDS-AFTER <CustomerOrders> <Customer> <Order> <OrdNum>100</OrdNum> <OrdTot>234.89</OrdTot> </Order> <CustNum>1</CustNum> <Name>Lift Tours</Name> </Customer> <OrdNum>200</OrdNum> <OrdTot>899.99</OrdTot> <CustNum>3</CustNum> <Name>Hoops</Name>  </Customer> </CustomerOrders> DEFINE TEMP-TABLE Customer FIELD CustNum AS INTEGER FIELD Name AS CHARACTER. DEFINE TEMP-TABLE Order FIELD OrdNum AS INTEGER FIELD OrdTot AS DECIMAL FIELD Customer_Id AS RECID XML-NODE-TYPE “Hidden”. DEFINE DATASET CustomerOrders FOR Customer, Order PARENT-ID-RELATION rel1 PARENT-ID-FIELD Customer_Id PARENT-FIELDS-AFTER (CustNum, Name).

XML-NODE-TYPE “Hidden” / SERIALIZE-HIDDEN on DATASET – 11.0 Root node maps to temp-table <person> <name>Ken</name>   <children>     <child age=“15”>Adam</child>     <child age=“20”>Elana</child>   </children> </person> DEFINE DATASET personDset XML-NODE-TYPE “HIDDEN” FOR person, children, child ...

Agenda XML in OpenEdge JSON in OpenEdge XML vs. JSON Q & A

JSON: JavaScript Object Notation Why JSON is Important JSON: JavaScript Object Notation Lightweight data exchange format – Alternative to XML http://json.org Use Cases Web development - JavaScript Libraries support JSON OE can easily become the back end of a Rich Internet Application (RIA) AppServer WebSpeed REST Adapter and OE Mobile use JSON – 11.2 Persistent storage between ABL sessions Less verbose than XML

Non-standard data types commonly used JSON Data Types Four simple data types string – “jump rope” number – 17, 54.35, 0.9582e-42 boolean – true, false null – null Non-standard data types commonly used date/time – “2011-09-21T11:00:00-04:00” binary – Base64 encoded string Complex data types Object Array

WRITE-JSON ( ) / READ-JSON ( ) - 10.2B WRITE-JSON ( mode, { file | stream | stream-handle | memptr | longchar } [, formatted [, encoding [, omit-initial-values [,omit-outer-object [, write-before-image ] ] ] ] ] ) *omit-outer-object added in 11.0 *write-before-image added in 11.4 READ-JSON ( source-type, { file | memptr | handle | longchar | JsonArray | JsonObject } [, read-mode ] ) *JsonArray and JsonObject added in 11.0

Gives you Control over JSON format JSON Attributes Gives you Control over JSON format Attribute Applies to... NESTED Data-Relation FOREIGN-KEY-HIDDEN (10.2A) SERIALIZE-NAME (10.2B) ProDataSet, Temp-Table and Buffer SERIALIZE-HIDDEN (10.2B) Buffer-Field PARENT-ID-RELATION (11.0)

Nested/Foreign-Key-Hidden - Data-Relation OpenEdge 10.2B Product Readiness Progress Software Corporation Internal Use Only December 2009 Nested/Foreign-Key-Hidden - Data-Relation DATASET CustOrder:GET-RELATION(“custOrd”):NESTED = TRUE. DATASET CustOrder:GET-RELATION(“custOrd”):FOREIGN-KEY-HIDDEN = TRUE. {"CustomerOrder": {                    "Customer": [                        {                        /* Row */       "CustNum": 1,        /* Column */ "Name": ["L","Frank","Baum"], "Balance": 55000.0,       "Order": [        {"OrderNum":100,"CustNum":1,"OrderDate":"2009-01-12"},          {"OrderNum":101,"CustNum":1,"OrderDate":"2009-01-12"}       ]     }   ] }} CustNum not present with FOREIGN-KEY-HIDDEN

WRITE-JSON – omit-outer-object – 11.0 omit-outer-object = FALSE omit-outer-object = TRUE {“tt”: [ {“f1”: 11, “f2”: 12}, {“f1”: 21, “f2”: 22}, {“f1”: 31, “f2”: 32} ]} [ {“f1”: 11, “f2”: 12}, {“f1”: 21, “f2”: 22}, {“f1”: 31, “f2”: 32} ]

ProDataSet - write-before-image = TRUE – 11.4 After table data ProDataSet - write-before-image = TRUE – 11.4 {"dsCustomer": { "prods:hasChanges": true, "ttCust": [ { "prods:id": "ttCust10497", "prods:rowState": "modified", "CustNum": 2, "NAME": "Urpon Frisbee_NewName", "Balance": 903.64 }, "prods:id": "ttCust10498", "prods:rowState": "created", "CustNum": 10, "NAME": "Customer10", "Balance": 56000.0 } ], Record marked as “modified” Record marked as “created”

ProDataSet – write-before-image = TRUE Before table data ProDataSet – write-before-image = TRUE "prods:before": { "ttCust": [ { "prods:id": "ttCust8449", "prods:rowState": "deleted", "CustNum": 3, "NAME": "Hoops", "Balance": 1199.95 }, "prods:id": "ttCust10497", "prods:rowState": "modified", "CustNum": 2, "NAME": "Urpon Frisbee", "Balance": 437.63 } ] Before-image of deleted record Before-image of modified record

Inferring Schema from JSON Data – READ-JSON ( ) OpenEdge 10.2B Product Readiness Progress Software Corporation Internal Use Only December 2009 Examines data to determine type CHARACTER (JSON string type) DECIMAL (JSON number type) LOGICAL (JSON boolean type) If all data values are null (?) CHARACTER Can infer NESTED Dataset Relationships Including PARENT-ID-RELATIONs

Buffer-Object:SERIALIZE-ROW ( ) – 11.0 Serialize ONLY current row Target-format “JSON” and “XML” Syntax SERIALIZE-ROW ( target-format, target-type, { file | stream | stream-handle | memptr | longchar } [, formatted [, encoding [, omit-initial-values [, omit-outer-object ] ] ] ] )

OOABL JSON API – JSON Object – 11.0 Progress.Json.ObjectModel.JsonObject Collection of name/value pairs No order Access by property name Object surrounded by curly braces { } Can INHERIT from { “name-1” : value-1, “name-2” : value-2, “name-3” : value-3}

JSON Object Example myObject = NEW JsonObject(). myObject:Add("name", "Dorothy Gale"). myObject:Add("age", 38). myObject:Add("region", "Kansas, USA"). myObject:Write(myLongchar, TRUE). myLongchar: { "name" : "Dorothy Gale",   "age" : 38,   "region" : "Kansas, USA" }                vChar = myObject:GetCharacter(“name”). vInt = myObject:GetInteger(“age”).

OOABL JSON API – JSON Array – 11.0 Progress.Json.ObjectModel.JsonArray Ordered list of unnamed values Strict order Access by array index Surrounded by square brackets [ ] Can INHERIT from [ value-1, value-2, value-3, value-4 ]

JSON Array Example myArray = NEW JsonArray(). myArray:Add(1). myArray:Add(FALSE). myArray.Add(“jump rope”). myArray:AddNull(). myArray:Write(myLongchar, TRUE). myLongchar: [ 1, false, “jump rope”, null ] myArray:Set(2, 6.0). vDec = myArray:GetDecimal(2). /* vDec = 6.0 */ vLog = myArray:GetLogical(4). /* vLog = ? */

Combination of simple values, objects and arrays Complex JSON Values Combination of simple values, objects and arrays {  "salesRep" : { "name" : "Dorothy Gale",                  "age" : 38,                  "region" : "Kansas, USA"                },  "tractorSales" : { "2009Quarterly" : [ 13, 27, 18, 9 ],                     "2008Quarterly" : [ 11, 17, 32, 5 ],                     "2007Quarterly" : [ 9, 25, 16, 10 ]                   } }

JSON API ProDataSet / Temp-Table Support JsonObject:Read ( ) Dataset Temp-Table Temp-Table Buffer JsonArray:Read ( ) READ-JSON ( ) Enhancement New source types JsonObject JsonArray

Agenda XML in OpenEdge JSON in OpenEdge XML vs. JSON Q & A

Consider the consumer of your data XML vs. JSON Advantages Disadvantages XML Extensible Formal XML Schema support (W3C) Datasets can interoperate with .NET format More verbose than JSON Can be memory Intensive - READ-XML cannot handle large docs JSON Lighter weight than XML Easily consumed by JavaScript, etc. Data maps directly to native variables Preferred for RESTful web services No formal schema support JSON Schema not in ABL Harder to deal with binary data Consider the consumer of your data

Google: XML vs. JSON “In terms of simplicity, openness, and interoperability, JSON and XML are tied.” “Both of these standards use Unicode standards and they both create data in a way the allows generic tools to manipulate the data.” https://www.udemy.com/blog/json-vs-xml “JSON is a better data exchange format. XML is a better document exchange format. Use the right tool for the right job.” “XML is document-oriented. JSON is data-oriented. JSON can be mapped more easily to object-oriented systems.” http://www.json.org/xml.html