castor

XMLInstance2Schema error skipping DateTime conversion

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.1
  • Fix Version/s: 1.1.1
  • Component/s: XML
  • Labels:
    None
  • Environment:
    Java 5
  • Testcase included:
    yes
  • Number of attachments :
    2

Description

I tried using the XMLInstance2Schema to convert an XML file to a schema file for castor to use, but I got the following exception:
java.lang.IllegalArgumentException: hour 42 must be strictly less than 24
at org.exolab.castor.types.DateTimeBase.setHour(DateTimeBase.java:311)
at org.exolab.castor.types.DateTimeBase.parseTime(DateTimeBase.java:1190)
at org.exolab.castor.types.Time.parseTimeInternal(Time.java:238)
at org.exolab.castor.types.Time.parseTime(Time.java:225)
at org.exolab.castor.xml.schema.util.DatatypeHandler.guessType(DatatypeHandler.java:188)
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.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.exolab.castor.xml.schema.util.XMLInstance2Schema.createSchema(XMLInstance2Schema.java:128)
at org.exolab.castor.xml.schema.util.XMLInstance2Schema.createSchema(XMLInstance2Schema.java:91)
at org.exolab.castor.xml.schema.util.XMLInstance2Schema.main(XMLInstance2Schema.java:159)

Here's a simple XML file to test the error:
<PARENT>
<CHILD id="CHILD_1">
<INNER id="INNER_25">4295 Mbs</INNER>
</CHILD>
</PARENT>

I created a quick fix to the DatatypeHandler.java by having it ignore IllegalArgumentException's as well as ParseException's when trying to parse a Time.

Patch:org/exolab/castor/xml/schema/util/DatatypeHandler.java
//-- check for time
try { Time.parseTime(value); return TIME_TYPE; }
catch(ParseException px) {}
catch(IllegalArgumentException ex) {}

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
20m
Original Estimate - 20 minutes
Remaining:
20m
Remaining Estimate - 20 minutes
Logged:
Not Specified
Time Spent - Not Specified