Thank you very much for answering so quickly.

I don't know if I have to report it elsewhere. 
Just in case I'm attaching here a small version of the file containing just one 
element of each type.
And here's the code I'm using to create the schema:

XMLInstance2Schema xi2s = new XMLInstance2Schema();
Schema schema = xi2s.createSchema("PATH TO: dummyControl1.xml");
Writer writer = new FileWriter("PATH TO: dummyControl1.xsd");
xi2s.serializeSchema(writer, schema);
writer.close();

Thanks again for your help.
Best regards,
Alejandro Salas.



>________________________________
> From: Werner Guttmann <[email protected]>
>To: [email protected] 
>Cc: Alejandro Salas <[email protected]> 
>Sent: Tuesday, September 11, 2012 3:13 AM
>Subject: Re: [castor-user] NullPointer using XMLInstance2Schema
> 
>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
>
>
>
>
>

Attachment: dummyControl1.xml
Description: Binary data

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to