SlideShare a Scribd company logo
1 of 54
Download to read offline
Copyright © 2012, Oracle and/or its affiliates. 1 All rights reserved.
Best Practices for 
Interoperable XML 
Databinding with JAXB 
Martin Grebac, 
SW Engineering Manager, Oracle 
(Project METRO)
The following is intended to outline our general product direction. It is intended 
for information purposes only, and may not be incorporated into any contract. 
It is not a commitment to deliver any material, code, or functionality, and should 
not be relied upon in making purchasing decisions. The development, release, 
and timing of any features or functionality described for Oracle’s products 
remains at the sole discretion of Oracle. 
Copyright © 2012, Oracle and/or its affiliates. 3 All rights reserved.
Program Agenda 
§ Quick intro 
§ Why? The Reasoning 
§ General Limitations & W3C approach 
§ Common-sense approach 
– Complexities to avoid 
– The safe intersection 
– Examples 
Copyright © 2012, Oracle and/or its affiliates. 4 All rights reserved.
Quick Intro 
Copyright © 2012, Oracle and/or its affiliates. 5 All rights reserved.
“XML data binding refers to a means of representing 
information in an XML document as an object in 
computer memory.” 
Wikipedia 
<Item ItemNumber="2"> 
<Part PartNumber="456"> 
<Description> bla bla…</Description> 
<Price>13.27</Price> 
</Part> 
<Quantity>5</Quantity> 
</Item> 
Copyright © 2012, Oracle and/or its affiliates. 6 All rights reserved. 
Item 
ItemNumber: 2 
Quantity: 5 
Part 
PartNumber: 456 
Description: bla bla … 
Price: 13.27
XML DataBinding – Where to Find 
§ Direct 
– Direct use of JAXB or other Databinding APIs 
§ Indirect 
– Web Services, JAX-WS, Jersey, REST, … 
§ Based on grammar (XML Schema, DTD, RelaxNG, …) 
– Classes usually represent the schema structures 
– Instances represent content of XML document 
– Schema feature set is large 
Copyright © 2012, Oracle and/or its affiliates. 7 All rights reserved.
WHY? - The Reasoning 
Copyright © 2012, Oracle and/or its affiliates. 8 All rights reserved.
Number of XML Databinding frameworks 
§ Axis 
§ .NET 
§ IBM RAD 
§ Mono 
§ gSOAP2 
§ Castor 
§ WCF 
§ JAXB 
§ XBinder 
Copyright © 2012, Oracle and/or its affiliates. 9 All rights reserved. 
§ SOAP4R 
§ Spring 
§ Castor 
§ Xbinder 
§ Xfire 
§ ZSI 
§ XMLBeans 
§ PHP 
§ ADB 
§ …
Common XML Databinding Framework 
Limitations 
§ Round-trip limitations 
– Sibling Order 
– Physical Structure 
– Comments and Processing Instructions 
– XML Declaration 
§ Feature limitations 
– Incomplete schema support 
– Transformations 
– Document Fragment support 
Copyright © 2012, Oracle and/or its affiliates. 10 All rights reserved.
Common XML Databinding Framework 
Limitations 
§ Round-trip limitations 
– Sibling Order 
– Physical Structure 
– Comments and Processing Instructions 
– XML Declaration 
§ Feature limitations 
– à Incomplete schema support 
– Transformations 
– Document Fragment support 
Copyright © 2012, Oracle and/or its affiliates. 11 All rights reserved.
Do you start from schema? 
Copyright © 2012, Oracle and/or its affiliates. 12 All rights reserved. 
XML Schema
Do you start from schema? 
Copyright © 2012, Oracle and/or its affiliates. 13 All rights reserved. 
XML Schema 
XML Document
Do you start from schema? 
Copyright © 2012, Oracle and/or its affiliates. 14 All rights reserved. 
XML Document 
Databinding 
/ 
Web Service 
framework 1 
Objects 
XML Schema 
Limited 
support
Or do you start from classes? 
Copyright © 2012, Oracle and/or its affiliates. 15 All rights reserved. 
XML Document 
Databinding 
/ 
Web Service 
framework 2 
Databinding 
/ 
Web Service 
framework 
1 
Objects 
Objects 
XML Schema 
Limited 
support 
Databinding 
/ 
Web Service 
framework 3 
Objects 
Limited 
support
Or do you start from classes? 
Copyright © 2012, Oracle and/or its affiliates. 16 All rights reserved. 
Objects
Or do you start from classes? 
Copyright © 2012, Oracle and/or its affiliates. 17 All rights reserved. 
XML Document 
Databinding 
/ 
Web Service 
framework 
1 
Objects
Or do you start from classes? 
Copyright © 2012, Oracle and/or its affiliates. 18 All rights reserved. 
XML Document 
Databinding 
/ 
Web Service 
framework 
1 
Objects 
XML Schema
Or do you start from classes? 
Copyright © 2012, Oracle and/or its affiliates. 19 All rights reserved. 
XML Document 
Databinding 
/ 
Web Service 
framework 
1 
Objects 
XML Schema
Or do you start from classes? 
Copyright © 2012, Oracle and/or its affiliates. 20 All rights reserved. 
XML Document 
Databinding 
/ 
Web Service 
framework 2 
Databinding 
/ 
Web Service 
framework 
1 
Objects 
Objects 
XML Schema 
Limited 
support
Or do you start from classes? 
Copyright © 2012, Oracle and/or its affiliates. 21 All rights reserved. 
XML Document 
Databinding 
/ 
Web Service 
framework 2 
Databinding 
/ 
Web Service 
framework 
1 
Objects 
Objects 
XML Schema 
Limited 
support 
Databinding 
/ 
Web Service 
framework 3 
Objects 
Limited 
support
Number of XML Databinding frameworks 
§ Axis 
§ .NET 
§ IBM RAD 
§ Mono 
§ gSOAP2 
§ Castor 
§ WCF 
§ JAXB 
§ XBinder 
Copyright © 2012, Oracle and/or its affiliates. 22 All rights reserved. 
§ SOAP4R 
§ Spring 
§ Castor 
§ Xbinder 
§ Xfire 
§ ZSI 
§ XMLBeans 
§ PHP 
§ ADB 
§ …
LOOKS PRETTY BAD … 
Copyright © 2012, Oracle and/or its affiliates. 23 All rights reserved.
LOOKS PRETTY BAD … 
… I’M DEPRESSED. 
Copyright © 2012, Oracle and/or its affiliates. 24 All rights reserved.
LOOKS PRETTY BAD … 
… I’M DEPRESSED. 
NOW WHAT? 
Copyright © 2012, Oracle and/or its affiliates. 25 All rights reserved.
Now what? 
The W3C Approach 
Copyright © 2012, Oracle and/or its affiliates. 26 All rights reserved.
W3C – The Ultimate Response 
§ Basic XML Schema Patterns for Databinding ~80 
– http://www.w3.org/TR/xmlschema-patterns/ 
– set of rules – “patterns” 
– conforming schemas shall claim best interoperable databinding 
– does not constrain the datamodel, e.g. primitive type representation 
§ Advanced XML Schema Patterns for Databinding ~220 
– these are known to *not* be well supported by some databinding 
frameworks/tools 
– http://www.w3.org/2002/ws/databinding/edcopy/advanced/advanced.html 
Copyright © 2012, Oracle and/or its affiliates. 27 All rights reserved.
W3C – Examples 
<xs:schema /> 
<xs:schema elementFormDefault=“qualified”/> 
@XmlSchema(elementFormDefault=XmlNsForm.QUALIFIED) 
package mypkg; 
<xs:schema elementFormDefault=“unqualified”/> 
@XmlSchema(elementFormDefault=XmlNsForm.UNQUALIFIED) 
package mypkg; 
Copyright © 2012, Oracle and/or its affiliates. 28 All rights reserved.
W3C – Examples 
<xs:schema /> 
<xs:schema attributeFormDefault=“unqualified”/> 
@XmlSchema(attributeFormDefault=XmlNsForm.UNQUALIFIED) 
package mypkg; 
<xs:schema attributeFormDefault=“qualified”/> 
@XmlSchema(attributeFormDefault=XmlNsForm.QUALIFIED) 
package mypkg; 
Copyright © 2012, Oracle and/or its affiliates. 29 All rights reserved.
W3C – Examples 
<xs:annotation> 
<xs:documentation>State Name</xs:documentation> 
</xs:annotation> 
<xs:annotation> 
<xs:documentation>State Name</xs:documentation> 
<xs:appinfo>Application Information</xs:appinfo> 
</xs:annotation> 
Copyright © 2012, Oracle and/or its affiliates. 30 All rights reserved.
W3C – Examples 
§ id=“1” 
§ import/include rules 
§ <xs:element name=“globalEl” type=“xs:string”> 
§ abstract==“false” 
§ … 
§ <xs:element name="non-Identifier-Name“> 
§ abstract==“true” 
§ minOccurs / maxOccurs 
§ … 
Copyright © 2012, Oracle and/or its affiliates. 31 All rights reserved.
Databinding interoperability 
§ Framework Language Passed Skip Fail 
– A Java 401 185 77 
– B Java 455 71 77 
– C Java 531 0 72 
– D C# 483 61 59 
– E Ruby 262 23 318 
– F Python 211 89 303 
– G C 548 1 54 
– H PHP 467 71 65 
– I C++ 465 38 100 
– J Java 448 33 122 
– K Java 499 58 46 
– … 
(source: http://www.w3.org/2002/ws/databinding/edcopy/report/basic.html) 
Copyright © 2012, Oracle and/or its affiliates. 32 All rights reserved.
Databinding interoperability 
(source: http://www.w3.org/2002/ws/databinding/edcopy/report/basic.html) 
Copyright © 2012, Oracle and/or its affiliates. 33 All rights reserved.
Databinding interoperability 
(source: http://www.w3.org/2002/ws/databinding/edcopy/report/basic.html) 
Copyright © 2012, Oracle and/or its affiliates. 34 All rights reserved.
Common-Sense Approach 
Copyright © 2012, Oracle and/or its affiliates. 35 All rights reserved.
Common-Sense Approach 
(JAXB view) 
Copyright © 2012, Oracle and/or its affiliates. 36 All rights reserved.
Common Sense Alternative 
§ No long list of patterns to keep in mind or check against 
§ Keep It Short & Simple 
§ Works both ways 
– Java à Schema 
– Schema à Java 
– Project based decision 
Copyright © 2012, Oracle and/or its affiliates. 37 All rights reserved.
Avoid problematic primitive types 
Copyright © 2012, Oracle and/or its affiliates. 38 All rights reserved. 
anySimpleType 
float decimal double 
integer 
long nonPositiveInteger nonNegativeInteger 
negativeInteger int unsignedLong positiveInteger 
short unsignedInt 
byte unsignedShort 
unsignedByte 
§ Boolean / boolean 
§ Byte / byte 
§ Short / short 
§ Integer / int 
§ Long / long 
§ Double / double 
§ BigInteger*
.NET Mapping 
§ System.Boolean 
§ System.SByte 
§ System.Int16 
§ System.Int32 
§ System.Int64 
§ System.Double 
§ System.UInt64* 
Copyright © 2012, Oracle and/or its affiliates. 39 All rights reserved. 
anySimpleType 
float decimal double 
integer 
long nonPositiveInteger nonNegativeInteger 
negativeInteger int unsignedLong positiveInteger 
short unsignedInt 
byte unsignedShort 
unsignedByte
Be Explicit. Use @XmlSchemaType 
@XmlElement 
@XmlSchemaType(name=“xs:long”) 
public Long lng; 
@XmlElement 
@XmlSchemaType(name=“xs:anyUri”) 
public java.net.URI uri; 
Copyright © 2012, Oracle and/or its affiliates. 40 All rights reserved.
Dates 
java.xml.datatype.XmlGregorianCalendar 
.NET: String 
Java: public XmlGregorianCalendar orderDate; 
XSD:<xs:element name=“orderDate” type=“xs:anySimpleType”/> 
java.util.Date 
java.util.Calendar 
Copyright © 2012, Oracle and/or its affiliates. 41 All rights reserved.
Be Explicit 
§ If direct date mapping required, still use XmlGregorianCalendar 
@XmlSchemaType(name=“dateTime”) 
public XMLGregorianCalendar orderDate; 
§ XSD: <xs:element name=“orderDate” type=“xs:dateTime”/> 
§ .NET: System.DateTime 
Copyright © 2012, Oracle and/or its affiliates. 42 All rights reserved.
Avoid Anonymous types 
<xsd:complexType name="PurchaseOrderType"> 
<xs:element name=“…” type=“ns:SomeOtherType”/> 
@XmlType() 
@XmlType(name=“SomeOtherType”) 
<xsd:complexType name="PurchaseOrderType"> 
… 
<xsd:complexType> … 
@XmlType(name=“”) 
Copyright © 2012, Oracle and/or its affiliates. 43 All rights reserved.
Avoid Mixed Content of Any Type 
<ex:notMixed> 
<ex:notMixedElement>Stuff</ex:notMixedElement> 
</ex:notMixed> 
<ex:mixed> 
<ex:element1>string</ex:element1>mixed content 
<ex:element2>string</ex:element2> 
mixed content 
</ex:mixed> 
@XmlMixed 
Copyright © 2012, Oracle and/or its affiliates. 44 All rights reserved.
Avoid Mixed Content of Any Type 
@XmlElement(name = “var1") 
protected short var1; 
@XmlElement(name = “var2") 
protected double var2; 
… 
@XmlElementRefs({ 
@XmlElementRef(name = “var1", type = JAXBElement.class), 
@XmlElementRef(name = “var2", type = JAXBElement.class), 
}) 
@XmlMixed 
protected List<Serializable> content; 
Copyright © 2012, Oracle and/or its affiliates. 45 All rights reserved.
Avoid substitution groups 
<element name="global" type="string" 
<element name="global-1" type="string" substitutionGroup="tns:global"/> 
<element name="global-2" type="string" substitutionGroup="tns:global"/> 
Copyright © 2012, Oracle and/or its affiliates. 46 All rights reserved.
Don’t Rely on Type Inheritance – by restriction 
<xs:complexType name=“parentType"> 
<xs:sequence> 
<xs:element name=“e1" type="xs:integer" minOccurs="0" maxOccurs="1"/> 
<xs:element name=“e2" type="xs:string" nillable="true" /> 
</xs:sequence> 
<xs:attribute name=“a1" type="xs:date" use="optional" /> 
</xs:complexType> 
<xs:complexType name=“childType"><xs:complexContent> 
<xs:restriction base=“parentType"> 
<xs:sequence> 
<xs:element name=“e1" type="xs:integer" minOccurs="1" /> 
<xs:element name=“e2" type="xs:string" nillable="false" /> 
</xs:sequence> 
<xs:attribute name=“a1" type="xs:date" use="required" /> 
</xs:restriction> 
</xs:complexContent></xs:complexType> 
Copyright © 2012, Oracle and/or its affiliates. 47 All rights reserved.
Common Sense Alternative 
§ Think about datatypes 
§ Be explicit 
§ Use XMLGregorianCalendar 
§ Avoid anonymous types 
§ Avoid mixed content! 
§ Avoid substitution groups 
§ Do not rely on inheritance by restriction 
Copyright © 2012, Oracle and/or its affiliates. 48 All rights reserved.
KEEP IT 
Copyright © 2012, Oracle and/or its affiliates. 49 All rights reserved.
KEEP IT 
Copyright © 2012, Oracle and/or its affiliates. 50 All rights reserved. 
SIMPLE
Common Sense Alternative 
§ http://jaxb.java.net 
§ http://blogs.oracle.com/mgrebac 
§ http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/reference/ 
tutorials/wsit/doc/WSITTutorial.pdf 
§ http://www.w3.org/TR/xmlschema-patterns/ 
§ http://www.w3.org/2002/ws/databinding/edcopy/advanced/advanced.html 
§ http://www.w3.org/2002/ws/databinding/patterns/6/09/ 
§ http://msdn.microsoft.com/en-us/library/ff842400%28d=printer%29.aspx 
§ http://www.infoq.com/articles/schema-for-ws-part1 
§ http://msdn.microsoft.com/en-us/netframework/gg413252 
§ http://www.ibm.com/developerworks/xml/library/ws-tip-j2eenet2/index.html 
§ http://www.ibm.com/developerworks/java/library/ws-tip-j2eenet3/index.html 
Copyright © 2012, Oracle and/or its affiliates. 51 All rights reserved.
Copyright © 2012, Oracle and/or its affiliates. 52 All rights reserved. 
Q 
& 
A
The preceding is intended to outline our general product direction. It is intended 
for information purposes only, and may not be incorporated into any contract. 
It is not a commitment to deliver any material, code, or functionality, and should 
not be relied upon in making purchasing decisions. The development, release, 
and timing of any features or functionality described for Oracle’s products 
remains at the sole discretion of Oracle. 
Copyright © 2012, Oracle and/or its affiliates. 53 All rights reserved.
Copyright © 2012, Oracle and/or its affiliates. 54 All rights reserved.

More Related Content

What's hot

Design Concepts For Xml Applications That Will Perform
Design Concepts For Xml Applications That Will PerformDesign Concepts For Xml Applications That Will Perform
Design Concepts For Xml Applications That Will PerformMarco Gralike
 
Advance java session 5
Advance java session 5Advance java session 5
Advance java session 5Smita B Kumar
 
JDBC Basics (In 20 Minutes Flat)
JDBC Basics (In 20 Minutes Flat)JDBC Basics (In 20 Minutes Flat)
JDBC Basics (In 20 Minutes Flat)Craig Dickson
 
Database connect
Database connectDatabase connect
Database connectYoga Raja
 
Hibernate - Part 2
Hibernate - Part 2 Hibernate - Part 2
Hibernate - Part 2 Hitesh-Java
 
Session 24 - JDBC, Intro to Enterprise Java
Session 24 - JDBC, Intro to Enterprise JavaSession 24 - JDBC, Intro to Enterprise Java
Session 24 - JDBC, Intro to Enterprise JavaPawanMM
 
Jdbc example program with access and MySql
Jdbc example program with access and MySqlJdbc example program with access and MySql
Jdbc example program with access and MySqlkamal kotecha
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESYoga Raja
 
Xml serialization
Xml serializationXml serialization
Xml serializationRaghu nath
 
JDBC Java Database Connectivity
JDBC Java Database ConnectivityJDBC Java Database Connectivity
JDBC Java Database ConnectivityRanjan Kumar
 
Java Servlet
Java ServletJava Servlet
Java ServletYoga Raja
 

What's hot (19)

Design Concepts For Xml Applications That Will Perform
Design Concepts For Xml Applications That Will PerformDesign Concepts For Xml Applications That Will Perform
Design Concepts For Xml Applications That Will Perform
 
JDBC Part - 2
JDBC Part - 2JDBC Part - 2
JDBC Part - 2
 
Jdbc[1]
Jdbc[1]Jdbc[1]
Jdbc[1]
 
Advance java session 5
Advance java session 5Advance java session 5
Advance java session 5
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
 
Database Access With JDBC
Database Access With JDBCDatabase Access With JDBC
Database Access With JDBC
 
22jdbc
22jdbc22jdbc
22jdbc
 
JDBC Basics (In 20 Minutes Flat)
JDBC Basics (In 20 Minutes Flat)JDBC Basics (In 20 Minutes Flat)
JDBC Basics (In 20 Minutes Flat)
 
Database connect
Database connectDatabase connect
Database connect
 
Jstl Guide
Jstl GuideJstl Guide
Jstl Guide
 
Jdbc
JdbcJdbc
Jdbc
 
Hibernate - Part 2
Hibernate - Part 2 Hibernate - Part 2
Hibernate - Part 2
 
Session 24 - JDBC, Intro to Enterprise Java
Session 24 - JDBC, Intro to Enterprise JavaSession 24 - JDBC, Intro to Enterprise Java
Session 24 - JDBC, Intro to Enterprise Java
 
Jdbc example program with access and MySql
Jdbc example program with access and MySqlJdbc example program with access and MySql
Jdbc example program with access and MySql
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGES
 
Xml serialization
Xml serializationXml serialization
Xml serialization
 
JDBC Java Database Connectivity
JDBC Java Database ConnectivityJDBC Java Database Connectivity
JDBC Java Database Connectivity
 
Java Servlet
Java ServletJava Servlet
Java Servlet
 
Xml & Java
Xml & JavaXml & Java
Xml & Java
 

Similar to Best Practices for Interoperable XML Databinding with JAXB

Ed presents JSF 2.2 at a 2013 Gameduell Tech talk
Ed presents JSF 2.2 at a 2013 Gameduell Tech talkEd presents JSF 2.2 at a 2013 Gameduell Tech talk
Ed presents JSF 2.2 at a 2013 Gameduell Tech talkEdward Burns
 
JavaOne-2013: Save Scarce Resources by Managing Terabytes of Objects off-heap...
JavaOne-2013: Save Scarce Resources by Managing Terabytes of Objects off-heap...JavaOne-2013: Save Scarce Resources by Managing Terabytes of Objects off-heap...
JavaOne-2013: Save Scarce Resources by Managing Terabytes of Objects off-heap...harvraja
 
GlassFish in Production Environments
GlassFish in Production EnvironmentsGlassFish in Production Environments
GlassFish in Production EnvironmentsBruno Borges
 
Node.js and Oracle Database: New Development Techniques
Node.js and Oracle Database: New Development TechniquesNode.js and Oracle Database: New Development Techniques
Node.js and Oracle Database: New Development TechniquesChristopher Jones
 
ADBA (Asynchronous Database Access)
ADBA (Asynchronous Database Access)ADBA (Asynchronous Database Access)
ADBA (Asynchronous Database Access)Logico
 
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 201310 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013Martin Fousek
 
pre-FOSDEM MySQL day, February 2018 - MySQL Document Store
pre-FOSDEM MySQL day, February 2018 - MySQL Document Storepre-FOSDEM MySQL day, February 2018 - MySQL Document Store
pre-FOSDEM MySQL day, February 2018 - MySQL Document StoreFrederic Descamps
 
MySQL Document Store - A Document Store with all the benefts of a Transactona...
MySQL Document Store - A Document Store with all the benefts of a Transactona...MySQL Document Store - A Document Store with all the benefts of a Transactona...
MySQL Document Store - A Document Store with all the benefts of a Transactona...Olivier DASINI
 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesJavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesMert Çalışkan
 
Looking Inside the MySQL 8.0 Document Store
Looking Inside the MySQL 8.0 Document StoreLooking Inside the MySQL 8.0 Document Store
Looking Inside the MySQL 8.0 Document StoreFrederic Descamps
 
Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Reza Rahman
 
Programming-best practices( beginner) ADF_fusionapps
Programming-best practices( beginner) ADF_fusionappsProgramming-best practices( beginner) ADF_fusionapps
Programming-best practices( beginner) ADF_fusionappsBerry Clemens
 
Ebs troubleshooting con9019_pdf_9019_0001
Ebs troubleshooting con9019_pdf_9019_0001Ebs troubleshooting con9019_pdf_9019_0001
Ebs troubleshooting con9019_pdf_9019_0001jucaab
 
Ed presents JSF 2.2 and WebSocket to Gameduell.
Ed presents JSF 2.2 and WebSocket to Gameduell.Ed presents JSF 2.2 and WebSocket to Gameduell.
Ed presents JSF 2.2 and WebSocket to Gameduell.Edward Burns
 
Lambdas and-streams-s ritter-v3
Lambdas and-streams-s ritter-v3Lambdas and-streams-s ritter-v3
Lambdas and-streams-s ritter-v3Simon Ritter
 
Oracle ADF Architecture TV - Development - Programming Best Practices
Oracle ADF Architecture TV - Development - Programming Best PracticesOracle ADF Architecture TV - Development - Programming Best Practices
Oracle ADF Architecture TV - Development - Programming Best PracticesChris Muir
 
ADF Mobile: Implementing Data Caching and Synching
ADF Mobile: Implementing Data Caching and SynchingADF Mobile: Implementing Data Caching and Synching
ADF Mobile: Implementing Data Caching and SynchingSteven Davelaar
 
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVMDiagnosing Your Application on the JVM
Diagnosing Your Application on the JVMStaffan Larsen
 

Similar to Best Practices for Interoperable XML Databinding with JAXB (20)

Ed presents JSF 2.2 at a 2013 Gameduell Tech talk
Ed presents JSF 2.2 at a 2013 Gameduell Tech talkEd presents JSF 2.2 at a 2013 Gameduell Tech talk
Ed presents JSF 2.2 at a 2013 Gameduell Tech talk
 
Java SE 8
Java SE 8Java SE 8
Java SE 8
 
JavaOne-2013: Save Scarce Resources by Managing Terabytes of Objects off-heap...
JavaOne-2013: Save Scarce Resources by Managing Terabytes of Objects off-heap...JavaOne-2013: Save Scarce Resources by Managing Terabytes of Objects off-heap...
JavaOne-2013: Save Scarce Resources by Managing Terabytes of Objects off-heap...
 
GlassFish in Production Environments
GlassFish in Production EnvironmentsGlassFish in Production Environments
GlassFish in Production Environments
 
Node.js and Oracle Database: New Development Techniques
Node.js and Oracle Database: New Development TechniquesNode.js and Oracle Database: New Development Techniques
Node.js and Oracle Database: New Development Techniques
 
ADBA (Asynchronous Database Access)
ADBA (Asynchronous Database Access)ADBA (Asynchronous Database Access)
ADBA (Asynchronous Database Access)
 
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 201310 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
 
pre-FOSDEM MySQL day, February 2018 - MySQL Document Store
pre-FOSDEM MySQL day, February 2018 - MySQL Document Storepre-FOSDEM MySQL day, February 2018 - MySQL Document Store
pre-FOSDEM MySQL day, February 2018 - MySQL Document Store
 
MySQL Document Store - A Document Store with all the benefts of a Transactona...
MySQL Document Store - A Document Store with all the benefts of a Transactona...MySQL Document Store - A Document Store with all the benefts of a Transactona...
MySQL Document Store - A Document Store with all the benefts of a Transactona...
 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesJavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
 
Looking Inside the MySQL 8.0 Document Store
Looking Inside the MySQL 8.0 Document StoreLooking Inside the MySQL 8.0 Document Store
Looking Inside the MySQL 8.0 Document Store
 
Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Have You Seen Java EE Lately?
Have You Seen Java EE Lately?
 
Programming-best practices( beginner) ADF_fusionapps
Programming-best practices( beginner) ADF_fusionappsProgramming-best practices( beginner) ADF_fusionapps
Programming-best practices( beginner) ADF_fusionapps
 
Ebs troubleshooting con9019_pdf_9019_0001
Ebs troubleshooting con9019_pdf_9019_0001Ebs troubleshooting con9019_pdf_9019_0001
Ebs troubleshooting con9019_pdf_9019_0001
 
Ed presents JSF 2.2 and WebSocket to Gameduell.
Ed presents JSF 2.2 and WebSocket to Gameduell.Ed presents JSF 2.2 and WebSocket to Gameduell.
Ed presents JSF 2.2 and WebSocket to Gameduell.
 
Lambdas and-streams-s ritter-v3
Lambdas and-streams-s ritter-v3Lambdas and-streams-s ritter-v3
Lambdas and-streams-s ritter-v3
 
Oracle ADF Architecture TV - Development - Programming Best Practices
Oracle ADF Architecture TV - Development - Programming Best PracticesOracle ADF Architecture TV - Development - Programming Best Practices
Oracle ADF Architecture TV - Development - Programming Best Practices
 
ADF Mobile: Implementing Data Caching and Synching
ADF Mobile: Implementing Data Caching and SynchingADF Mobile: Implementing Data Caching and Synching
ADF Mobile: Implementing Data Caching and Synching
 
Cloud based database
Cloud based databaseCloud based database
Cloud based database
 
Diagnosing Your Application on the JVM
Diagnosing Your Application on the JVMDiagnosing Your Application on the JVM
Diagnosing Your Application on the JVM
 

Recently uploaded

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedDelhi Call girls
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 

Recently uploaded (20)

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 

Best Practices for Interoperable XML Databinding with JAXB

  • 1. Copyright © 2012, Oracle and/or its affiliates. 1 All rights reserved.
  • 2. Best Practices for Interoperable XML Databinding with JAXB Martin Grebac, SW Engineering Manager, Oracle (Project METRO)
  • 3. The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. Copyright © 2012, Oracle and/or its affiliates. 3 All rights reserved.
  • 4. Program Agenda § Quick intro § Why? The Reasoning § General Limitations & W3C approach § Common-sense approach – Complexities to avoid – The safe intersection – Examples Copyright © 2012, Oracle and/or its affiliates. 4 All rights reserved.
  • 5. Quick Intro Copyright © 2012, Oracle and/or its affiliates. 5 All rights reserved.
  • 6. “XML data binding refers to a means of representing information in an XML document as an object in computer memory.” Wikipedia <Item ItemNumber="2"> <Part PartNumber="456"> <Description> bla bla…</Description> <Price>13.27</Price> </Part> <Quantity>5</Quantity> </Item> Copyright © 2012, Oracle and/or its affiliates. 6 All rights reserved. Item ItemNumber: 2 Quantity: 5 Part PartNumber: 456 Description: bla bla … Price: 13.27
  • 7. XML DataBinding – Where to Find § Direct – Direct use of JAXB or other Databinding APIs § Indirect – Web Services, JAX-WS, Jersey, REST, … § Based on grammar (XML Schema, DTD, RelaxNG, …) – Classes usually represent the schema structures – Instances represent content of XML document – Schema feature set is large Copyright © 2012, Oracle and/or its affiliates. 7 All rights reserved.
  • 8. WHY? - The Reasoning Copyright © 2012, Oracle and/or its affiliates. 8 All rights reserved.
  • 9. Number of XML Databinding frameworks § Axis § .NET § IBM RAD § Mono § gSOAP2 § Castor § WCF § JAXB § XBinder Copyright © 2012, Oracle and/or its affiliates. 9 All rights reserved. § SOAP4R § Spring § Castor § Xbinder § Xfire § ZSI § XMLBeans § PHP § ADB § …
  • 10. Common XML Databinding Framework Limitations § Round-trip limitations – Sibling Order – Physical Structure – Comments and Processing Instructions – XML Declaration § Feature limitations – Incomplete schema support – Transformations – Document Fragment support Copyright © 2012, Oracle and/or its affiliates. 10 All rights reserved.
  • 11. Common XML Databinding Framework Limitations § Round-trip limitations – Sibling Order – Physical Structure – Comments and Processing Instructions – XML Declaration § Feature limitations – à Incomplete schema support – Transformations – Document Fragment support Copyright © 2012, Oracle and/or its affiliates. 11 All rights reserved.
  • 12. Do you start from schema? Copyright © 2012, Oracle and/or its affiliates. 12 All rights reserved. XML Schema
  • 13. Do you start from schema? Copyright © 2012, Oracle and/or its affiliates. 13 All rights reserved. XML Schema XML Document
  • 14. Do you start from schema? Copyright © 2012, Oracle and/or its affiliates. 14 All rights reserved. XML Document Databinding / Web Service framework 1 Objects XML Schema Limited support
  • 15. Or do you start from classes? Copyright © 2012, Oracle and/or its affiliates. 15 All rights reserved. XML Document Databinding / Web Service framework 2 Databinding / Web Service framework 1 Objects Objects XML Schema Limited support Databinding / Web Service framework 3 Objects Limited support
  • 16. Or do you start from classes? Copyright © 2012, Oracle and/or its affiliates. 16 All rights reserved. Objects
  • 17. Or do you start from classes? Copyright © 2012, Oracle and/or its affiliates. 17 All rights reserved. XML Document Databinding / Web Service framework 1 Objects
  • 18. Or do you start from classes? Copyright © 2012, Oracle and/or its affiliates. 18 All rights reserved. XML Document Databinding / Web Service framework 1 Objects XML Schema
  • 19. Or do you start from classes? Copyright © 2012, Oracle and/or its affiliates. 19 All rights reserved. XML Document Databinding / Web Service framework 1 Objects XML Schema
  • 20. Or do you start from classes? Copyright © 2012, Oracle and/or its affiliates. 20 All rights reserved. XML Document Databinding / Web Service framework 2 Databinding / Web Service framework 1 Objects Objects XML Schema Limited support
  • 21. Or do you start from classes? Copyright © 2012, Oracle and/or its affiliates. 21 All rights reserved. XML Document Databinding / Web Service framework 2 Databinding / Web Service framework 1 Objects Objects XML Schema Limited support Databinding / Web Service framework 3 Objects Limited support
  • 22. Number of XML Databinding frameworks § Axis § .NET § IBM RAD § Mono § gSOAP2 § Castor § WCF § JAXB § XBinder Copyright © 2012, Oracle and/or its affiliates. 22 All rights reserved. § SOAP4R § Spring § Castor § Xbinder § Xfire § ZSI § XMLBeans § PHP § ADB § …
  • 23. LOOKS PRETTY BAD … Copyright © 2012, Oracle and/or its affiliates. 23 All rights reserved.
  • 24. LOOKS PRETTY BAD … … I’M DEPRESSED. Copyright © 2012, Oracle and/or its affiliates. 24 All rights reserved.
  • 25. LOOKS PRETTY BAD … … I’M DEPRESSED. NOW WHAT? Copyright © 2012, Oracle and/or its affiliates. 25 All rights reserved.
  • 26. Now what? The W3C Approach Copyright © 2012, Oracle and/or its affiliates. 26 All rights reserved.
  • 27. W3C – The Ultimate Response § Basic XML Schema Patterns for Databinding ~80 – http://www.w3.org/TR/xmlschema-patterns/ – set of rules – “patterns” – conforming schemas shall claim best interoperable databinding – does not constrain the datamodel, e.g. primitive type representation § Advanced XML Schema Patterns for Databinding ~220 – these are known to *not* be well supported by some databinding frameworks/tools – http://www.w3.org/2002/ws/databinding/edcopy/advanced/advanced.html Copyright © 2012, Oracle and/or its affiliates. 27 All rights reserved.
  • 28. W3C – Examples <xs:schema /> <xs:schema elementFormDefault=“qualified”/> @XmlSchema(elementFormDefault=XmlNsForm.QUALIFIED) package mypkg; <xs:schema elementFormDefault=“unqualified”/> @XmlSchema(elementFormDefault=XmlNsForm.UNQUALIFIED) package mypkg; Copyright © 2012, Oracle and/or its affiliates. 28 All rights reserved.
  • 29. W3C – Examples <xs:schema /> <xs:schema attributeFormDefault=“unqualified”/> @XmlSchema(attributeFormDefault=XmlNsForm.UNQUALIFIED) package mypkg; <xs:schema attributeFormDefault=“qualified”/> @XmlSchema(attributeFormDefault=XmlNsForm.QUALIFIED) package mypkg; Copyright © 2012, Oracle and/or its affiliates. 29 All rights reserved.
  • 30. W3C – Examples <xs:annotation> <xs:documentation>State Name</xs:documentation> </xs:annotation> <xs:annotation> <xs:documentation>State Name</xs:documentation> <xs:appinfo>Application Information</xs:appinfo> </xs:annotation> Copyright © 2012, Oracle and/or its affiliates. 30 All rights reserved.
  • 31. W3C – Examples § id=“1” § import/include rules § <xs:element name=“globalEl” type=“xs:string”> § abstract==“false” § … § <xs:element name="non-Identifier-Name“> § abstract==“true” § minOccurs / maxOccurs § … Copyright © 2012, Oracle and/or its affiliates. 31 All rights reserved.
  • 32. Databinding interoperability § Framework Language Passed Skip Fail – A Java 401 185 77 – B Java 455 71 77 – C Java 531 0 72 – D C# 483 61 59 – E Ruby 262 23 318 – F Python 211 89 303 – G C 548 1 54 – H PHP 467 71 65 – I C++ 465 38 100 – J Java 448 33 122 – K Java 499 58 46 – … (source: http://www.w3.org/2002/ws/databinding/edcopy/report/basic.html) Copyright © 2012, Oracle and/or its affiliates. 32 All rights reserved.
  • 33. Databinding interoperability (source: http://www.w3.org/2002/ws/databinding/edcopy/report/basic.html) Copyright © 2012, Oracle and/or its affiliates. 33 All rights reserved.
  • 34. Databinding interoperability (source: http://www.w3.org/2002/ws/databinding/edcopy/report/basic.html) Copyright © 2012, Oracle and/or its affiliates. 34 All rights reserved.
  • 35. Common-Sense Approach Copyright © 2012, Oracle and/or its affiliates. 35 All rights reserved.
  • 36. Common-Sense Approach (JAXB view) Copyright © 2012, Oracle and/or its affiliates. 36 All rights reserved.
  • 37. Common Sense Alternative § No long list of patterns to keep in mind or check against § Keep It Short & Simple § Works both ways – Java à Schema – Schema à Java – Project based decision Copyright © 2012, Oracle and/or its affiliates. 37 All rights reserved.
  • 38. Avoid problematic primitive types Copyright © 2012, Oracle and/or its affiliates. 38 All rights reserved. anySimpleType float decimal double integer long nonPositiveInteger nonNegativeInteger negativeInteger int unsignedLong positiveInteger short unsignedInt byte unsignedShort unsignedByte § Boolean / boolean § Byte / byte § Short / short § Integer / int § Long / long § Double / double § BigInteger*
  • 39. .NET Mapping § System.Boolean § System.SByte § System.Int16 § System.Int32 § System.Int64 § System.Double § System.UInt64* Copyright © 2012, Oracle and/or its affiliates. 39 All rights reserved. anySimpleType float decimal double integer long nonPositiveInteger nonNegativeInteger negativeInteger int unsignedLong positiveInteger short unsignedInt byte unsignedShort unsignedByte
  • 40. Be Explicit. Use @XmlSchemaType @XmlElement @XmlSchemaType(name=“xs:long”) public Long lng; @XmlElement @XmlSchemaType(name=“xs:anyUri”) public java.net.URI uri; Copyright © 2012, Oracle and/or its affiliates. 40 All rights reserved.
  • 41. Dates java.xml.datatype.XmlGregorianCalendar .NET: String Java: public XmlGregorianCalendar orderDate; XSD:<xs:element name=“orderDate” type=“xs:anySimpleType”/> java.util.Date java.util.Calendar Copyright © 2012, Oracle and/or its affiliates. 41 All rights reserved.
  • 42. Be Explicit § If direct date mapping required, still use XmlGregorianCalendar @XmlSchemaType(name=“dateTime”) public XMLGregorianCalendar orderDate; § XSD: <xs:element name=“orderDate” type=“xs:dateTime”/> § .NET: System.DateTime Copyright © 2012, Oracle and/or its affiliates. 42 All rights reserved.
  • 43. Avoid Anonymous types <xsd:complexType name="PurchaseOrderType"> <xs:element name=“…” type=“ns:SomeOtherType”/> @XmlType() @XmlType(name=“SomeOtherType”) <xsd:complexType name="PurchaseOrderType"> … <xsd:complexType> … @XmlType(name=“”) Copyright © 2012, Oracle and/or its affiliates. 43 All rights reserved.
  • 44. Avoid Mixed Content of Any Type <ex:notMixed> <ex:notMixedElement>Stuff</ex:notMixedElement> </ex:notMixed> <ex:mixed> <ex:element1>string</ex:element1>mixed content <ex:element2>string</ex:element2> mixed content </ex:mixed> @XmlMixed Copyright © 2012, Oracle and/or its affiliates. 44 All rights reserved.
  • 45. Avoid Mixed Content of Any Type @XmlElement(name = “var1") protected short var1; @XmlElement(name = “var2") protected double var2; … @XmlElementRefs({ @XmlElementRef(name = “var1", type = JAXBElement.class), @XmlElementRef(name = “var2", type = JAXBElement.class), }) @XmlMixed protected List<Serializable> content; Copyright © 2012, Oracle and/or its affiliates. 45 All rights reserved.
  • 46. Avoid substitution groups <element name="global" type="string" <element name="global-1" type="string" substitutionGroup="tns:global"/> <element name="global-2" type="string" substitutionGroup="tns:global"/> Copyright © 2012, Oracle and/or its affiliates. 46 All rights reserved.
  • 47. Don’t Rely on Type Inheritance – by restriction <xs:complexType name=“parentType"> <xs:sequence> <xs:element name=“e1" type="xs:integer" minOccurs="0" maxOccurs="1"/> <xs:element name=“e2" type="xs:string" nillable="true" /> </xs:sequence> <xs:attribute name=“a1" type="xs:date" use="optional" /> </xs:complexType> <xs:complexType name=“childType"><xs:complexContent> <xs:restriction base=“parentType"> <xs:sequence> <xs:element name=“e1" type="xs:integer" minOccurs="1" /> <xs:element name=“e2" type="xs:string" nillable="false" /> </xs:sequence> <xs:attribute name=“a1" type="xs:date" use="required" /> </xs:restriction> </xs:complexContent></xs:complexType> Copyright © 2012, Oracle and/or its affiliates. 47 All rights reserved.
  • 48. Common Sense Alternative § Think about datatypes § Be explicit § Use XMLGregorianCalendar § Avoid anonymous types § Avoid mixed content! § Avoid substitution groups § Do not rely on inheritance by restriction Copyright © 2012, Oracle and/or its affiliates. 48 All rights reserved.
  • 49. KEEP IT Copyright © 2012, Oracle and/or its affiliates. 49 All rights reserved.
  • 50. KEEP IT Copyright © 2012, Oracle and/or its affiliates. 50 All rights reserved. SIMPLE
  • 51. Common Sense Alternative § http://jaxb.java.net § http://blogs.oracle.com/mgrebac § http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/reference/ tutorials/wsit/doc/WSITTutorial.pdf § http://www.w3.org/TR/xmlschema-patterns/ § http://www.w3.org/2002/ws/databinding/edcopy/advanced/advanced.html § http://www.w3.org/2002/ws/databinding/patterns/6/09/ § http://msdn.microsoft.com/en-us/library/ff842400%28d=printer%29.aspx § http://www.infoq.com/articles/schema-for-ws-part1 § http://msdn.microsoft.com/en-us/netframework/gg413252 § http://www.ibm.com/developerworks/xml/library/ws-tip-j2eenet2/index.html § http://www.ibm.com/developerworks/java/library/ws-tip-j2eenet3/index.html Copyright © 2012, Oracle and/or its affiliates. 51 All rights reserved.
  • 52. Copyright © 2012, Oracle and/or its affiliates. 52 All rights reserved. Q & A
  • 53. The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. Copyright © 2012, Oracle and/or its affiliates. 53 All rights reserved.
  • 54. Copyright © 2012, Oracle and/or its affiliates. 54 All rights reserved.