[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-user
Subject:    RE: does this get recognized as a Nil value?
From:       "Radu Preotiuc-Pietro" <radup () bea ! com>
Date:       2005-11-18 0:09:27
Message-ID: 4B2B4C417991364996F035E1EE39E2E10294F529 () uskiex01 ! amer ! bea ! com
[Download RAW message or body]

Yeah, obviously the empty string "" is not valid representation for the
"xsd:decimal" type so XmlBeans is correct when complaining. Moreover,
this is one of the "unclear how to recover" issues, so we preferred to
throw an exception instead of, say, the 0 value.

If you had control over the input document, the best approach would be
to change it to
    <nillable xsi:nil="true"></nillable>
and that would have worked.

If you have control over the Schema, the best thing is to bite the
bullet, change the type to "xsd:string" and then do the conversion in
Java.

If you don't have control over either one, you would have to catch the
exception and write code that uses XmlObject.newCursor().getTextValue()
to see the original value in the document and do something special if it
is "" (convert it to nil, though in some cases people may want the
default value 0)

Radu

-----Original Message-----
From: Kevin Y. Kim (Lists) [mailto:kykim_lists@mac.com] 
Sent: Tuesday, November 08, 2005 10:25 AM
To: user@xmlbeans.apache.org
Subject: does this get recognized as a Nil value?


Hi,

If I have a schema element like this:
	<xsd:element name="nillable" type="xsd:decimal"
nillable="true"/>

and end up with an xml like this:
	<nillable></nillable>

When I parse that xml with xmlbeans, I seem to get an 
XmlValueOutOfRangeException
for the methods: isNilNillable() and getNillable().

So I have a couple of questions:
	- Shouldn't my XML get parsed as nil?
	- If not, is there a way to specify the schema so it is parsed
as nil?

For complicated reasons, I don't necessarily control the XML I'm 
recieving.
Also, I'm actually invoking the isNil... and get... methods via 
reflection,
so I'm having trouble actually catching the exception.

Thanks,
-kevin


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic