Re: readInt and WXS [Re: CVS Update: xmlpull-api-v1/addons/java/wrapper/src/org/xmlpull/v1/wrapper/classic]
Dennis Sosnoski <[email protected]> Tue, 01 Jul 2003 23:43:40 -0700
| Newsgroups | gmane.text.xml.xmlpull.devel |
|---|---|
| Message-ID | <[email protected]> |
As I understand it, the requirement to trim whitespace before conversion is yet another ugly little WXS wart. WXS requires whitespace normalization of all primitive types other than xsd:string and derived types. This is implied by the whiteSpace facet, which is fixed as "collapse" for all these types. See http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#rf-whiteSpace for details. Elliotte Rusty Harold mentioned the issue of trimming whitespace on the JDOM list a while ago, which was the first I'd seen of it. I've got a mental note to address this in JiBX at some point. - Dennis Aleksander Slominski wrote: >Dennis Sosnoski wrote: > > > >>You're going to have some problems with these. For one thing, >>Integer.parseInt() will blow up with a leading '+' sign >> >> >> >i did not know about this limitaiton - quite interesintg - i would >think "+10" is legal integer - also interesting problem is what is the >most optimized way to read and convert into string into integer (maybe >read from char[] buffer directly?) > > > >>and parseDouble()/parseFloat() will accept some values that WXS does not >>allow. >> >> >> >yes but they are (were?) common in some SOAP implementations - so >following philosophy of being generous in what one accepts ... though >maybe it should not be applied to WXS .. > > > >>Finally, you need to trim leading and trailing whitespace on the >>text values before parsing them for compatibility with WXS. >> >> >> >why is it required - i am only caring about parsed avlue (i.e. double) >and lexical representation (toString()) should be fine? > > > >>You might want to check my JiBX code for handling the WXS types: >> >>http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jibx/distrib/build/src/org/jibx/runtime/Utility.java >> >> >>This has date/time handling as well as the numeric types. The methods >>don't trim the whitespace, but that can easily be handled before calling >>them. >> >> >> >thanks i copied parseInt() method. i have not even started to think how >to deal with data/time from WXS. it seems that only reliable way is to >have special java classes that mimic how gYear and friends are defined >or do lot of checking each time int is passed and reated as year ... > >thanks, > >alek > > > ------------------------ Yahoo! Groups Sponsor ---------------------~--> Get A Free Psychic Reading! Your Online Answer To Life's Important Questions. http://us.click.yahoo.com/Lj3uPC/Me7FAA/ySSFAA/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/