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:[EMAIL PROTECTED]
Sent: Tuesday, November 08, 2005 10:25 AM
To: [email protected]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]