JXON An Architecture for Schema and Annotation Driven JSON/XML Bidirectional Transformations David A. Lee Senior Principal Software Engineer Slide 1.

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

XML: Extensible Markup Language
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
1 Web Data Management XML Schema. 2 In this lecture XML Schemas Elements v. Types Regular expressions Expressive power Resources W3C Draft:
SPECIAL TOPIC XML. Introducing XML XML (eXtensible Markup Language) ◦A language used to create structured documents XML vs HTML ◦XML is designed to transport.
An Introduction to XML Based on the W3C XML Recommendations.
An Introductory Tutorial. Background and Purpose.
Sistemi basati su conoscenza XML Prof. M.T. PAZIENZA a.a
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.
XML(EXtensible Markup Language). XML XML stands for EXtensible Markup Language. XML is a markup language much like HTML. XML was designed to describe.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
Introduction to XML: Yong Choi CSU Bakersfield.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
MC 365 – Software Engineering Presented by: John Ristuccia Shawn Posts Ndi Sampson XSLT Introduction BCi.
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
SD2520 Databases using XML and JQuery
Pemrograman Berbasis WEB XML part 2 -Aurelio Rahmadian- Sumber: w3cschools.com.
From a Single Ontologically Sound Conceptual Model to Multiple Physical Schema Languages Bruce T. Bauman, U.S. DoD 1.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
1 XML at a neighborhood university near you Innovation 2005 September 16, 2005 Kwok-Bun Yue University of Houston-Clear Lake.
XML  JSON Lossless reversible transformation Epocrates, Inc. David A. Lee Senior Principle Software Engineer Tom Angelopoulos, Staff Engineer.
CSE4500 Information Retrieval Systems XML Schema – Part 1.
XML CPSC 315 – Programming Studio Fall 2008 Project 3, Lecture 1.
XSLT for Data Manipulation By: April Fleming. What We Will Cover The What, Why, When, and How of XSLT What tools you will need to get started A sample.
XML eXtensible Markup Language w3c standard Why? Store and transport data Easy data exchange Create more languages WSDL (Web Service Description Language)
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
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.
Intro. to XML & XML DB Bun Yue Professor, CS/CIS UHCL.
Session IV Chapter 9 – XML Schemas
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
Avoid using attributes? Some of the problems using attributes: Attributes cannot contain multiple values (child elements can) Attributes are not easily.
How do I use HTML and XML to present information?.
XML A web enabled data description language 4/22/2001 By Mark Lawson & Edward Ryan L’Herault.
Lecture 11 XSL Transformations (part 1: Introduction)
XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard.
Of 33 lecture 3: xml and xml schema. of 33 XML, RDF, RDF Schema overview XML – simple introduction and XML Schema RDF – basics, language RDF Schema –
New Perspectives on XML, 2nd Edition
 XML DTD and XML Schema Discussion Sessions 1A and 1B Session 2.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Understanding How XML Works Ellen Pearlman Eileen Mullin Programming the.
An Introduction to XML Paul Donohue May 8th 2002 Hotel Senator Zürich.
1 XML eXtensible Markup Language. 2 XML vs. HTML HTML is a HyperText Markup language HTML is a HyperText Markup language Designed for a specific application,
XML 2nd EDITION Tutorial 4 Working With Schemas. XP Schemas A schema is an XML document that defines the content and structure of one or more XML documents.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
1 Indexing The syntax for creating a index is: CREATE [UNIQUE] INDEX index_name ON table_name (column1, column2,... column_n) [ COMPUTE STATISTICS ]; Why.
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.
Web Technologies Lecture 4 XML and XHTML. XML Extensible Markup Language Set of rules for encoding a document in a format readable – By humans, and –
Martin Kruliš by Martin Kruliš (v1.1)1.
Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.
Lecture 23 XQuery 1.0 and XPath 2.0 Data Model. 2 Example 31.7 – User-Defined Function Function to return staff at a given branch. DEFINE FUNCTION staffAtBranch($bNo)
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
CHAPTER NINE Accessing Data Using XML. McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved Introduction The eXtensible.
XML – Basic Concepts (modified version from Dr. Praveen Madiraju) 2015, Fall Pusan National University Ki-Joune Li.
XML Extensible Markup Language
XML Schema – XSLT Week 8 Web site:
1 XSL Transformations (XSLT). 2 XSLT XSLT is a language for transforming XML documents into XHTML documents or to other XML documents. XSLT uses XPath.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
XML & JSON. Background XML and JSON are to standard, textual data formats for representing arbitrary data – XML stands for “eXtensible Markup Language”
1 XML eXtensible Markup Language. 2 Introduction and Motivation Dr. Praveen Madiraju Modified from Dr.Sagiv’s slides.
Extensible Markup Language (XML) Pat Morin COMP 2405.
XML BASICS and more…. What is XML? In common:  XML is a standard, simple, self-describing way of encoding both text and data so that content can be processed.
Unit 4 Representing Web Data: XML
XML QUESTIONS AND ANSWERS
XML in Web Technologies
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
Chapter 7 Representing Web Data: XML
CS 240 – Advanced Programming Concepts
XML: The new standard -Eric Taylor.
Presentation transcript:

JXON An Architecture for Schema and Annotation Driven JSON/XML Bidirectional Transformations David A. Lee Senior Principal Software Engineer Slide 1

An experiment... Slide 2

This Presentation... IS  Research  Goals  Architecture  How it works !  Case Study  Full of tiny examples  A working implementation ready for download now IS NOT  Life, the Universe and Everything  Complete details – see the paper for more  An answer to everything  Fulfillment of all goals  API Documentation Slide 3

Markup Domains Slide 4

In the Ideal World... Slide 5

JSON and XML would be equivalent... XML My Favorite Book 1.23 XML for Dummies 5.25 JSON for Dummies JSON { "BOOKS" : [ { "id" : "1", "title": "My Favorite Book", "price" : 1.23 }, { "id" : "1a", "title": "XML for Dummies", "price" : 5.25}, { "id" : "3", "title": "JSON for Dummies", "price" : } ]} Slide 6

JSON != XML – they just don't translate easily  How would a translation know to consistently use a string value for "id" and "title" but a numeric value for "price" ?  Where does the "BOOK" element come from when translating to XML ?  How does the JSON to XML transformation code know to make "id" into an attribute in XML but not price or title ?  How does the XML to JSON translation know to construct an array in JSON ?  Where does the name conversion rule for "TITLE" vs. "title" and "PRICE" vs. "price" occur ? Slide 7

In reality... Slide 8

In Reality – json.org XML to JSON { "childNodes": [ { "childNodes": [ { "childNodes": ["My Favorite Book"], "tagName": "TITLE" }, { "childNodes": [1.23], "tagName": "PRICE" } ], "id": 1, "tagName": "BOOK" }, Slide 9 { "childNodes": [ { "childNodes": ["JSON for Dummies"], "tagName": "TITLE" }, { "childNodes": [200.95], "tagName": "PRICE" } ], "id": 3, "tagName": "BOOK" } ], "tagName": "BOOKS“ } { "childNodes": [ { "childNodes": ["XML for Dummies"], "tagName": "TITLE" }, { "childNodes": [5.25], "tagName": "PRICE" } ], "id": "1a", "tagName": "BOOK" },

In Reality – json.org JSON to XML 1 My Favorite Book a XML for Dummies JSON for Dummies Slide 10 Not Well Formed

Interesting Issues  Inconsistent typing of the "id" value  Very verbose and complex JSON representation  JSON arrays where simple values should be used  Pairs of 'name/value' members where native JSON member names should be used  Unnecessary distinctions between how attributes and child elements are serialized Slide 11

JXON Goals Slide 12 JSON and XML Converge

JXON Goals  Simple specification for XML to/from JSON transformations  Results are what authors actually want  Markup agnostic (not biased to either XML or JSON)  Make use of Schema information and annotations to guide transformations Slide 13

JSON / XML – What’s the problem? JSON “Hello World” XML Hello World or Slide 14 Anonymous Values

JSON / XML – What’s the problem? JSON [ 1, "String" ] XML 1 String 1 String <array entry1="1" entry2="String"/> 1 String Slide 15 Arrays

JSON / XML – What’s the problem? JSON “value”: “1.5” or “value”: 1.5 XML 1.5 Slide 16 Implicit Types (e.g. "Duck Typing")

JSON / XML – What’s the problem? Many more issues …  Identifiers  Namespaces  Processing Instructions  Attributes  Character Set  Comments  Document Node  Serialization format  Character Encodings Slide 17

Existing Designs and Implementations  The JSON to XML converter from json.org  JSONx  Badgerfish  Rabbitfish  JSON Markup Language (JsonML)  XSLTJSON, XML to JSON using XSLT  XML to JSON jQuery Plugin  Boomerang - A bidirectional programming language for ad- hoc, textual data.  XSugar - Dual Syntax for XML Languages  OGF Standards: Data Format Description Language (DFDL) Slide 18

General Categories of existing implementations  Represent arbitrary JSON in an XML format Result: A very ugly XML format  Represent arbitrary XML in a JSON format Result: A very ugly JSON format  Convert XML to JSON in a JSON friendly format Result: Works only for simple XML documents Loses or crashes on unexpected content  Convert JSON to XML in a XML friendly format Result: Works only for simple JSON documents Loses or crashes on unexpected content Slide 19

Liberty vs. Equality  Inequality will exist as long as liberty exists. It unavoidably results from that very liberty itself. — Alexander Hamilton GM — Syd Bauman – Balisage 2011 Slide 20

Classes of transformations Slide 21

JXON Overview Slide 22

JSON to XML Slide 23

XML to JSON Slide 24

JXON internal implementation Slide 25

Schema and Annotations  XSD or RNG (XML) schema Provides type information Provides element and attribute use  Annotations Provide the general “pattern” for the document Apply specific overrides for transformation rules o Elements o Attributes o Types o Text o Children handling Slide 26

Patterns  Apply a set of rule properties to a name (“rule”)  Rule properties work together to form transformation styles  Extensible  May be mixed and applied to individual items  Support for 2 patterns currently – more to come Full o A completely lossless bidirectional pattern Simple o A common pattern for simple schemas o Lossless and bidirectional for a subset of schemas Slide 27

Element Rules  Name translations  Attribute handling  Child element handling  Text handling  Types Slide 28

Attribute Rules  Name translations  Object wrapping  Types Slide 29

Full Pattern Slide 30

“full” pattern on the full schema default namespace = "" # grammar { start = Books Books = element BOOKS { Book+ } Book = element BOOK { attribute id { xsd:NMTOKEN }, Title, Price } Title = element TITLE { text } Price = element PRICE { xsd:decimal } } Slide 31

Full Sample XML My Favorite Book 1.23 XML for Dummies 5.25 JSON for Dummies JSON { "BOOKS": { "_children": ["\n ", { "BOOK": { "_attributes": { "id":"1" }, "_children": ["\n ", { "TITLE": { "_children": ["My Favorite Book"] } },"\n ", { "PRICE": { "_children": [1.23] } },"\n "] } },"\n ", … Slide 32

Simple Pattern Slide 33

“simple” pattern on the full schema default namespace = "" # grammar { start = Books Books = element BOOKS { Book+ } Book = element BOOK { attribute id { xsd:NMTOKEN }, Title, Price } Title = element TITLE { text } Price = element PRICE { xsd:decimal } } Slide 34

Simple Sample XML My Favorite Book 1.23 XML for Dummies 5.25 JSON for Dummies JSON { "BOOKS": { "BOOK": { "id":"1", "TITLE":"My Favorite Book", "PRICE":1.23 }, "BOOK": { "id":"1a", "TITLE":"XML for Dummies", "PRICE":5.25 }, "BOOK": { "id":"3", "TITLE":"JSON for Dummies", "PRICE": } Slide 35 Invalid JSON

Modified Example - RNG default namespace = "" # grammar { start = Books # Books = element BOOKS { Book+ } # Book = element BOOK { attribute id { xsd:NMTOKEN }, Title, Price } # Title = element TITLE { text } # Price = element PRICE { xsd:decimal } } Slide 36

Modified Example - XSD <xs:element maxOccurs="unbounded" ref="BOOK"/> Slide 37 <xs:attribute name="id" use="required" type="xs:NMTOKEN"/>

The Ideal World – Its real, its now ! XML My Favorite Book 1.23 XML for Dummies 5.25 JSON for Dummies JSON { "BOOKS" : [ { "id" : "1", "title": "My Favorite Book", "price" : 1.23 }, { "id" : "1a", "title": "XML for Dummies", "price" : 5.25}, { "id" : "3", "title": "JSON for Dummies", "price" : } ] } Slide 38

Not quite... Slide 39 Still in the Steam Age...

Limitations, Issues  Requires an XML Schema Starting with JSON is more difficult then XML  Recursive Structures not handled well No way to target different rules for different levels  Namespaces Limited support for managing namespaces  Lossy vs. Lossless vs. Bidirectional Tools do not tell you what the result will be  Efficiency can produce huge XSLT files  Mixed Content Works but not elegantly handled  Schema Aware XSLT Slide 40

An experiment... Slide 41 Schema information can be valuable in guiding transformations Annotations are a workable notation JSON/XML transformation is hard ! Nothing will make everyone happy or solve every use case A mixture of languages can work well Java + XQuery+ XSLT+ Scripting Software is still fun !

A long track ahead... Slide 42 Thank you ! David A. Lee For download visit: Open Source. BSD License.