Hi Alejandro,
yes, this looks like a bug. But please do not forget to attach all
relevant artefacts required so that we can easily replay your problem.
In addition, please strip down the XML files as much as possible.
Kind Regards
Werner Guttmann
On 11.09.2012 07:45, Alejandro Salas wrote:
Hello everyone,
I'm trying to use XMLInstance2Schema. I followed the code sample from
the javadoc but I'm getting a NullPointerException in
XMLInstance2SchemaHandler, line 520.
I don't know if this is the correct behavior or if this is a bug.
Somewhere during the parsing of my xml e1.getType() in line 487 returns
null, next there are a couple of ifs, in my case the execution goes to
line 493 and 494. The problem is that e1Type is never set to e2Type so
it's still null when it arrives at 520. The same thing happens in the if
from 507, e2Type is not being set. On both of the else clause (line 496
and 409) the variables are being set.
Is this a bug? Should I report it?
I attached the xml I'm using.
Here's part of the method from XMLInstance2SchemaHandler.
487XMLType e1Type = e1.getType();
488 XMLType e2Type = e2.getType();
489
490 //-- Make sure types are not null and if so create them
491 if (e1Type == null) {
492 if (e2Type == null) return; //-- nothing to merge
493if (e2Type.isSimpleType()) {
494 e1.setType(e2Type);
495}
496else {
497 ComplexType cType = new ComplexType(_schema);
498 Group group = new Group();
499 group.setOrder(_defaultGroupOrder);
500 cType.addGroup(group);
501 e1.setType(cType);
502 e1Type = cType;
503}
504 }
505 else if (e2Type == null) {
506 if (e1Type.isSimpleType()) {
507 e2.setType(e1Type);
508 }
509 else {
510 ComplexType cType = new ComplexType(_schema);
511 Group group = new Group();
512 group.setOrder(_defaultGroupOrder);
513 cType.addGroup(group);
514 e2.setType(cType);
515 e2Type = cType;
516 }
517 }
518
519 //-- both simple types
520 if (e1Type.isSimpleType() && e2Type.isSimpleType()) {
Thanks in advance!
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email