yeshodhan / android-jaxb

Android doesn't support JAXB. Use this library to generate SimpleXML annotated classes from XML Schema. Works well with Android.
https://s3.amazonaws.com/yeshodhan/android-jaxb-1.0.1.jar
41 stars 17 forks source link

NPE generating classes from XSD with type=date, dateTime or base64Binary #9

Open barrypitman opened 8 years ago

barrypitman commented 8 years ago

When I try generate classes from an XSD that contains type="date", type="dateTime" or type="base64Binary" as an attribute or element type, I get a NullPointerException, as follows:

$ java -jar android-jaxb-1.0.1.jar schemas/testSchema.xsd --destination . --package com.test Code Generator Initialized. Destination Directory: . [Element /GetCountriesResponse Min Occurs: null, Max Occurs: null ] of type [null][Start of sequence Min Occurs: 1, Max Occurs: 1 ] [Element /GetCountriesResponse/Countries Min Occurs: 0, Max Occurs: -1 ] of type [TestElement] [Attribute /GetCountriesResponse/Countries/@code Min Occurs: 1, Max Occurs: 1 ] of type [string] [Attribute /GetCountriesResponse/Countries/@description Min Occurs: 1, Max Occurs: 1 ] of type [string] [Attribute /GetCountriesResponse/Countries/@date Min Occurs: 1, Max Occurs: 1 ] of type [date] Exception in thread "main" java.lang.NullPointerException at com.sun.codemodel.JVar.annotate(JVar.java:188) at com.mickoo.xml.xsd2simplexml.GeneratedClass.addElement(GeneratedClass.java:62) at com.mickoo.xml.xsd2simplexml.SchemaParser.addSimpleType(SchemaParser.java:300) at com.mickoo.xml.xsd2simplexml.SchemaParser.processAttribute(SchemaParser.java:263) at com.mickoo.xml.xsd2simplexml.SchemaParser.processComplexType(SchemaParser.java:242) at com.mickoo.xml.xsd2simplexml.SchemaParser.processElement(SchemaParser.java:368) at com.mickoo.xml.xsd2simplexml.SchemaParser.processParticle(SchemaParser.java:208) at com.mickoo.xml.xsd2simplexml.SchemaParser.processGroup(SchemaParser.java:219) at com.mickoo.xml.xsd2simplexml.SchemaParser.processParticle(SchemaParser.java:204) at com.mickoo.xml.xsd2simplexml.SchemaParser.processComplexType(SchemaParser.java:232) at com.mickoo.xml.xsd2simplexml.SchemaParser.processElement(SchemaParser.java:368) at com.mickoo.xml.xsd2simplexml.SchemaParser.parse(SchemaParser.java:67) at com.mickoo.xml.xsd2simplexml.Main.main(Main.java:80)

testSchema.xsd.txt

yeshodhan commented 8 years ago

Taking a look.

barrypitman commented 8 years ago

Ideally, it would generate fields with the following types: type="date" -> java.sql.Date type="dateTime" -> java.sql.Timestamp type="base64Binary" -> byte[] But I'm not sure how well that will play with simplexml.