Re: XML Schema types to Java

Dennis Sosnoski <[email protected]> Sun, 09 Mar 2003 14:42:12 -0800
Newsgroups gmane.text.xml.xmlpull.devel
Message-ID <[email protected]>
Aleksander Slominski wrote:

>Naresh Bhatia wrote:
>
>>Anyone know of a good library to convert XML Schema types to Java and 
>>back. Specifically I am trying to convert xsd:dateTime to 
>>java.util.Date and back.
>>    
>>
>i would check castor.exolab.org as it must have something like that 
>implemented and it is actively developed (so well tested) and has good 
>open source license (so you can use it in your apps and not worry about 
>viral licensing ...) otherwise check also JaxME and other XML 
>databinding libraries as there is many of them currently - one list of 
>available packages is at the end of Dennis Sosnoski article: 
>http://www-106.ibm.com/developerworks/library/x-databdopt2/#resources
>
I don't know how well Castor's code has really been tested - I tried a 
few experiments when I was doing my performance tests and found it 
rejected int values with a leading plus sign ("+3"), which are perfectly 
legal in Schema. It looked like they were just using the standard Java 
library code for at least this conversion.

There are quite a few subtle difference between the Java library 
implementations and the Schema standard. This is especially true for the 
date/time handling, where Schema calls for a proleptic Gregorian 
calendar (one that applies back before the actual origin of the 
calendar) while Java implements the Gregorian calendar with a 
discontinuity. This abviously won't matter to most people - dates from 
1600 and earlier aren't exactly common in modern business documents! - 
but it's obviously best to have a library implement the proper handling.

I've got a set of conversions implemented in my JiBX code that I've been 
testing in preparation for the upcoming beta. The code is now in CVS at 
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jibx/distrib/build/src/org/jibx/runtime/Utility.java, 
with the JUnit tests at 
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jibx/distrib/build/src/test/jibx/runtime/UtilityTest.java 
Besides being tested vs the Schema specification (modulo any 
misinterpretations by me), both the int parsing and the date/time 
conversions in both directions are considerably faster than the Java 
versions.

  - Dennis


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/xaxhjB/hdqFAA/xGHJAA/2U_rlB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[email protected]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/