castor-data-binding / castor

http://castor-data-binding.github.io/castor/
35 stars 29 forks source link

IllegalArgumentException from DatatypeHandler for XML to XSD generation #56

Open cyrilantony opened 8 years ago

cyrilantony commented 8 years ago
Caused by: java.lang.IllegalArgumentException: month 66 is out of range:  1 <= month <= 12
    at org.exolab.castor.types.DateTimeBase.setMonth(DateTimeBase.java:250)
    at org.exolab.castor.types.Date.parseDateInternal(Date.java:293)
    at org.exolab.castor.types.Date.parseDate(Date.java:240)
    at org.exolab.castor.xml.schema.util.DatatypeHandler.guessType(DatatypeHandler.java:181)
    at org.exolab.castor.xml.schema.util.XMLInstance2SchemaHandler.endElement(XMLInstance2SchemaHandler.java:220)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.exolab.castor.xml.schema.util.XMLInstance2Schema.createSchema(XMLInstance2Schema.java:143)
    at org.exolab.castor.xml.schema.util.XMLInstance2Schema.createSchema(XMLInstance2Schema.java:120)

Fix: In https://github.com/castor-data-binding/castor/blob/1.3.2/schema/src/main/java/org/exolab/castor/xml/schema/util/DatatypeHandler.java At line:180 after these

try {
      Date.parseDate(value);
      return DATE_TYPE;
    } catch (ParseException px) {
    } 

catch the IllegalArgumentException also

catch (java.lang.IllegalArgumentException px) {
}
wguttmn commented 8 years ago

Mind creating a pull request ?

cyrilantony commented 8 years ago

No issues. I can send a pull request. To which branch shall I send ?

wguttmn commented 8 years ago

Against master

wguttmn commented 8 years ago

Just follow the general instructions on github, and you’ll be fine.

Werner

On 26 Jul 2016, at 12:40, Cyril ANTONY notifications@github.com wrote:

No issues. I can send a pull request. To which branch shall I send ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

wguttmn commented 8 years ago

What's the input you actually used when running into this problem ?