Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/DesignDocs/217508"
Line 168: | Line 168: | ||
System.out.println("OBJECT: " + o + " ("+ o.getClass() + ")"); | System.out.println("OBJECT: " + o + " ("+ o.getClass() + ")"); | ||
... | ... | ||
− | |||
− | |||
− | |||
− | |||
</source> | </source> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Result: | Result: | ||
+ | <source> | ||
OBJECT: 16.0 (class java.lang.Double) | OBJECT: 16.0 (class java.lang.Double) | ||
</source> | </source> |
Revision as of 14:50, 5 February 2008
Support for Root Elements representing Simple Types
Document History
Date | Author | Version Description & Notes |
---|---|---|
2008-02-01 | Rick Barkhouse | Initial Draft |
Project overview
This project will add the ability for EclipseLink OX to unmarshal XML documents that have simple types as their root element. Instead of a "rich" top-level element representing a domain object (e.g. Employee
, PurchaseOrder
), the root element may be a simple primitive value.
Goals:
- Allow the user to unmarshal XML documents that contain simple type root elements.
Concepts
The following concepts are used in this document:
- Simple Type - one of the basic, "built-in" types available in XML Schema. These may represent basic Java primitives (such as
xsd:boolean
andxsd:float
), or more robust types (xsd:hexBinary
,xsd:dateTime
,xsd:QName
). XML Schema has two categories of simple types; Primitive Types (the most basic of data type), and Derived Types (other simple types that are defined in terms of primitive types).
XML Schema Primitive Data Types | ||||||
---|---|---|---|---|---|---|
string | boolean | decimal | float | double | duration | dateTime |
time | date | gYearMonth | gYear | gMonthDay | gDay | gMonth |
hexBinary | base64Binary | anyURI | QName | NOTATION | ||
XML Schema Derived Data Types | ||||||
normalizedString | token | language | NMTOKEN | NMTOKENS | Name | NCName |
ID | IDREF | IDREFS | ENTITY | ENTITIES | integer | nonPositiveInteger |
negativeInteger | long | int | short | byte | nonNegativeInteger | unsignedLong |
unsignedInt | unsignedShort | unsignedByte | positiveInteger |
For more information see: http://www.w3.org/TR/xmlschema-2/#built-in-datatypes
Requirements
The requirements for this project are as follows:
- Support unmarshalling of XML instance documents that contain Simple Type (both primitive and derived) root elements.
- Support marshalling "primitive" Java objects to XML.
- Ensure that the proper
ConversionManager
is used when converting XML to Java. - Ensure that the proper
ClassLoader
is used when converting values.
For example, the JAXB TCK uses the following types of test documents:
XML Schema - The schema contains a single element, a restriction (extension) of the base64Binary
simple type:
<schema ...> ... <element name="NISTSchema-base64Binary-enumeration" type="nist:NISTSchema-base64Binary-enumeration-Type"/> <simpleType name="NISTSchema-base64Binary-enumeration-Type"> <restriction base="base64Binary"> <enumeration value="bHlsY2JmaXFjaW9ubmg="/> </restriction> </simpleType> </schema>
XML Instance Document - The document contains a single element with value zGk=
:
<NISTSchema-base64Binary-enumeration xmlns="NISTSchema-base64Binary-enumeration-NS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="NISTSchema-base64Binary-enumeration-NS enumeration.xsd">zGk=</NISTSchema-base64Binary-enumeration>
Functionality
Use Case 1: Root Element is a Primitive Simple Type
Schema (primitive.xsd
):
... <element name="aSimpleValue" type="mySimpleType"/> <simpleType name="mySimpleType"> <restriction base="double"> <enumeration value="4"/> <enumeration value="8"/> <enumeration value="15"/> <enumeration value="16"/> <enumeration value="23"/> <enumeration value="42"/> </restriction> </simpleType> ...
Instance Document (primitive-1.xml
):
<aSimpleValue>16</aSimpleValue>
EclipseLink Code:
... MyProject proj = new MyProject(); XMLContext ctx = new XMLContext(proj); Object o = ctx.createUnmarshaller().unmarshal(new File("primitive-1.xml")); System.out.println("OBJECT: " + o + " ("+ o.getClass() + ")"); ...
Result:
Invalid language.
You need to specify a language like this: <source lang="html4strict">...</source>
Supported languages for syntax highlighting:
4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, arm, asm, asp, asymptote, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcl, dcpu16, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, freeswitch, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, haxe, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, ldif, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, nagios, netrexx, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, octave, oobas, oorexx, oracle11, oracle8, otj, oxygene, oz, parasail, parigp, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, pys60, python, q, qbasic, rails, rebol, reg, rexx, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, spark, sparql, sql, stonescript, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, upc, urbi, uscript, vala, vb, vbnet, vedit, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic
OBJECT: 16.0 (class java.lang.Double)
Documentation
EclipseLink User Documentation should be updated to demonstrate how documents containing Simple Type root elements are supported.
Open Issues
Issue # | Owner | Description / Notes |
---|
Issue # | Description / Notes | Decision |
---|