From XML Schema to JSON Schema - Comparison and ...

Ulm University | 89069 Ulm | Germany

From XML Schema to JSON Schema Comparison and Translation

with Constraint Handling Rules

Bachelor Thesis at the University of Ulm

Submitted by:

Falco Nogatz

falco.nogatz@uni-ulm.de

Reviewer:

Prof. Dr. Thom Frhwirth

2013

Faculty of

Engineering and

Computer Science

Institute of Software

Engineering and Compiler

Construction

Version December 10, 2013

c 2013 Falco Nogatz

This work is licensed under the Creative Commons. Attribution-NonCommercial-ShareAlike 3.0

License. To view a copy of this license, visit or

send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California,

94105, USA.

Satz: PDF-LATEX 2

Abstract

This thesis identifies similar semantics in the two schema definition languages XML

Schema and JSON Schema to build a dictionary which covers typical use cases to

automatically transform first to the latter. As the range of functions of both XML Schema

and JSON Schema are not identical, concrete transformation rules to reproduce similar

behavior of data constraints are discussed and implemented by use of the logic programming language Constraint Handling Rules. As a result, a Prolog library xsd2json is

created which provides tools to translate complex XML Schema documents into their

equivalent JSON Schema documents.

iii

Contents

1. Introduction

1

1.1. Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1

1.2. Scope of this Thesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3

1.3. Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3

1.4. Road Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3

2. Technologies

5

2.1. XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5

2.2. XML Schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

8

2.3. JSON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2.4. JSON Schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.5. Prolog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2.6. Constraint Handling Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

3. General Translation Process

17

3.1. Read in XML Schema into Prolog . . . . . . . . . . . . . . . . . . . . . . . 19

3.2. XML Flattening . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

3.3. Setting Defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

3.4. Fragment Translation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

3.5. Wrap JSON Schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

3.6. Clean up and JSON Output . . . . . . . . . . . . . . . . . . . . . . . . . . 32

4. Translation Rules

35

4.1. XSD Primitive Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

v

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download