Flexible Data-binding With RelaxNGCC Kohsuke Kawaguchi

Slides:



Advertisements
Similar presentations
J0 1 Marco Ronchetti - Web architectures – Laurea Specialistica in Informatica – Università di Trento Java XML parsing.
Advertisements

Vilmos Zsombori , Shanghai
CPSC 388 – Compiler Design and Construction
Introduction to Maven 2.0 An open source build tool for Enterprise Java projects Mahen Goonewardene.
W3C XML Schema: what you might not know (and might or might not like!) Noah Mendelsohn Distinguished Engineer IBM Corp. October 10, 2002.
JAXB Java Architecture for XML Binding Andy Fanton Khalid AlBayat.
XML Parsing Using Java APIs AIP Independence project Fall 2010.
4 July 2005 overview Traineeship: Mapping of data structures in multiprocessor systems Nick de Koning
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
31 Signs That Technology Has Taken Over Your Life: #6. When you go into a computer store, you eavesdrop on a salesperson talking with customers -- and.
Exception Handling An Exception is an indication of a problem that occurs during a program’s execution. Exception handling enables the programmer to create.
1 Substitution Groups in XML Schemas Tomer Shiran Winter 2003/4 Semester.
Fonts and colors Times New Roman “quotes” Trebuchet "quotes" yellow blue pink green violet.
29-Jun-15 JAXB Java Architecture for XML Binding.
1 understanding xml namespaces. 2 understanding namespaces Namespaces are the source of much confusion in XML, especially for those new to the technology.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
ANTLR Andrew Pangborn & Zach Busser. ANTLR in a Nutshell ANother Tool for Language Recognition generates lexers generates parsers (and parse trees)‏ Java-based,
Appendix A.2: Review of Java and Object-Oriented Programming: Part 2 “For the object-oriented project, remember that the primary unit of decomposition.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Form Handling.
Parallel Programming in Java with Shared Memory Directives.

2.2 A Simple Syntax-Directed Translator Syntax-Directed Translation 2.4 Parsing 2.5 A Translator for Simple Expressions 2.6 Lexical Analysis.
An Extension to XML Schema for Structured Data Processing Presented by: Jacky Ma Date: 10 April 2002.
Robert Fourer, Jun Ma, Kipp Martin Optimization Services Instance Language (OSiL), Solvers, and Modeling Languages Kipp Martin University of Chicago
A Simplified Approach to Web Service Development Peter Kelly Paul Coddington Andrew Wendelborn.
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.
Using the Actions Pane, Host Controls, and Smart Tags
SAX Parsing Presented by Clifford Lemoine CSC 436 Compiler Design.
Intro. to XML & XML DB Bun Yue Professor, CS/CIS UHCL.
Putting it all together: LINQ as an Example. The Problem: SQL in Code Programs often connect to database servers. Database servers only “speak” SQL. Programs.
1 Dr Alexiei Dingli XML Technologies XML Advanced.
1 JavaScript in Context. Server-Side Programming.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
Fall 2007cs4201 Advanced Java Programming Umar Kalim Dept. of Communication Systems Engineering
Introduction to Exception Handling and Defensive Programming.
Managing Extended Attributes With an Enterprise Guide Add-In Larry Hoyle, Institute for Policy & Social Research, University of Kansas.
CS 153: Concepts of Compiler Design August 26 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Ant & Jar Ant – Java-based build tool Jar – pkzip archive, that contains metadata (a manifest file) that the JRE understands.
ActionScript 3 Extensible Markup Language (XML) by Martin Stanhope The University of Bolton.
Python Functions.
Run-Time Storage Organization Compiler Design Lecture (03/23/98) Computer Science Rensselaer Polytechnic.
JAVA COURSE 1 Computer Engineering Association. Compile your first program Public class Hello{ public class Hello(){ System.out.println(“Hello”); } puclic.
AxKit A member of the Apache XML project Ryan Maslyn Kyle Bechtel.
COP4020 Programming Languages Exception Handling Prof. Robert van Engelen (modified by Prof. Em. Chris Lacher)
Chapter 1 Introduction Major Data Structures in Compiler
Class Builder Tutorial Presented By- Amit Singh & Sylendra Prasad.
Oracle Data Integrator User Functions, Variables and Advanced Mappings
Herzog August Bibliothek Wolfenbüttel Backend, Service, Listener VuFind's new SOLR connection Originally Presented By David Maus Herzog August Bibliothek.
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
CSE 130 : Winter 2009 Programming Languages Lecture 11: What’s in a Name ?
Experience with XML Schema Ashok Malhotra Schema Usage  Mapping XML Schema and XML documents controlled by the Schema to object classes and instances.
BY: JAKE TENBERG & CHELSEA SHIPP PROJECT REVIEW: JGIBBERISH.
JoiMint Graphical objects and their XML configuration files Piotr K. Bartkiewicz, DESY, MST-1.
Python: Building Geoprocessing Tools David Wynne, Ghislain Prince.
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
Design Overview. Generated Packages ► fUML.Library.* - generated ► fUML.Semantics.* - generated ► fUML.Syntax.* - generated ► fUML.Test.* - generated.
1 Validation SAX-DOM. Objectives 2  Schema Validation Framework  XML Validation After Transformation  Workshops.
Lecture 9:FXML and Useful Java Collections Michael Hsu CSULA.
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
LECTURE 19 Subroutines and Parameter Passing. ABSTRACTION Recall: Abstraction is the process by which we can hide larger or more complex code fragments.
Lecture Transforming Data: Using Apache Xalan to apply XSLT transformations Marc Dumontier Blueprint Initiative Samuel Lunenfeld Research Institute.
OGP Seabed Survey Data Model (SSDM)
Teaching Compiler Design
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
Lecture Set 3 Introduction to Visual Basic Concepts
Java Programming Course
Presentation transcript:

Flexible Data-binding With RelaxNGCC Kohsuke Kawaguchi

2 What ’ s RelaxNGCC?  RelaxNGCC is:  Parser generator (e.g., YACC, JavaCC, or ANTLR)  Data-binding tool (e.g., JAXB, Castor, or Relaxer)  Purpose  To simplify XML parsing development

3 Before RelaxNGCC  But writing SAX handler...  Is hard and tiring  Takes time  Is routine and not fun XML Parser XML document Hand-written SAX Handler So people turn their eyes to data-binding

4 Problems With Data-binding Tools  Impedance mismatch b/w XML and ideal OM  What does (A|B|C)* mean?  Customization is limited  Generated code is low in quality  Expose a lot of unnecessary methods

5 Problems With Data-binding Tools  Unable to bridge existing code and existing schema  Take time to get used to the generated code  Need to know how schemas are mapped

6 After RelaxNGCC  Reduces development time XML Parser XML document Generated SAX Handler Annotated RELAX NG Schema

7 How RelaxNGCC Works?  By associating code and schema number= name= System.out.println("start"); number= System.out.print(number+":"); name= System.out.println(name); System.out.println("end");

8 Key Concepts  Anchoring data to variables Values are copied to specified variables as document gets parsed number=

9 Key Concepts  Code will be also executed at the "right" moment me you start 1:me 2:you end

10 Key Concepts  Pattern blocks work like function calls passing data down and up across boundaries result= j= result= (3); j= i+=Integer.parseInt(j);

11 Code Generation  Each pattern block gets its own class  At runtime, new object is allocated to process new block Class Foo Class Bar

12 Code Generation  Aliases become fields  Additional methods can be defined *** 1 *** *** 2 *** abc = import x.y.z; *** 1 *** class Foo { *** 2 *** String abc;... }

13 Runtime  Code used to help generated code  Just 3 classes  No runtime version dependency  Runtime receives SAX events and coordinate handlers SAX events Generated Runtime Generated SAX Handler Generated SAX Handler Generated Handlers

14 Runtime  Provides services to user-specified code  Retrieve Locator object  Resolve namespace prefix  Redirect sub-tree to another SAX ContentHandler

15 Runtime  User-defined code can be added  Added methods/fields available to handlers  Useful to keep global info SAX events Default Runtime Customized Runtime extend Generated SAX Handler Generated SAX Handler Generated Handlers access

16 Runtime (example) runtime.myFunction();... class MyRuntime extends NGCCRuntime { public void myFunction() {... }

17 Put in Practice  Reading XML configuration file  Extend runtime to hold Options class  Fill in the structure as you go through document name = value= runtime.opt.properties.put( name,value); runtime.opt.paramX = class Options { Properties properties; String paramX; } class MyRuntime : NGCCRuntime { public Options opt; }

18 Put in Practice  Quickly build Abstract Syntax Tree  Just use generated class hierarchy and their fields  Use cc:class to throw in extra classes public Set params; p= name = value= params.add(p); paramX =

19 Put in Practice  Build full-blown object model  RelaxNGCC uses itself to parse RELAX NG  Design OM without worrying about syntax  Then use RelaxNGCC to build a parser for that Good efficient parser in short time

20 Why RELAX NG?  Cannot write annotation like this  How can I anchor 10 values to 10 different variables?  No way!...

21 Why RELAX NG?  Formal model makes RelaxNGCC simple  Simpler state management  Simpler schema parsing  Uniform treatment of attributes/elements

22 Why RELAX NG?  Some XML Schema features don't work well  Nillable  Type substitution  Substitution group... ironic because all those features are supposed to be for data-oriented XMLs

23 Loosely-coupled Systems  Type sharing makes systems tightly-coupled  Some says that's what XML is trying to avoid  Better to share the syntax w/o sharing data model  RelaxNGCC allows you to do this!

24 License  Compiler  GPL  Generated code, including runtime  All yours!

25 To Get More Information  Project web-site   Contact developers   RELAX NG Info   This presentation 

26 End  Acknowledgement  Daisuke Okajima, the inventor of RelaxNGCC  Sun Microsystems, for allowing me to work on RELAX NG  Any Question?