qiuwei / jing-trang

Automatically exported from code.google.com/p/jing-trang
Other
1 stars 1 forks source link

Convert From XML to XSD :- instance timestamp value conversion - NMTOKEN type takes priority over dateTime #76

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Convert the attached SampleXML.xml file to XSD

What is the expected output? What do you see instead?

I expect to see value testDate="2004-07-21T10:00:00.000" converted to a 
dateTime type in the resulting XSD. Instead I see :-
<xs:attribute name="testDate" use="required" type="xs:NMTOKEN"/>

What version of the product are you using? On what operating system?
Latest trunk source, Windows XP Professional JDK1.6

Please provide any additional information below.

1. Type conversion priority appears to be controlled by the order of the 
type list in the class com.thaiopensource.xml.infer.DatatypeRepertoire

e.g

  static private final String[] typeNames = {
    "boolean",
    // XXX add int?
    "integer",
    "decimal",
    "double",
    "NCName",
    "NMTOKEN",
    "time",
    "date",
    "dateTime",
    "duration",
    "hexBinary",
    "base64Binary",
    "anyURI"
  };

The value "2004-07-21T10:00:00.000" will match NMTOKEN and dateTime, but 
as NMToken appears in the list before dateTime, therefore it is the chosen 
type, but not the most appropriate.

An obvious fix would be to shuffle the list so that NCName and NMTOKEN 
appear between the type anyURI and base64Binary. However I am not sure if 
this would have any knock on effect. 

Original issue reported on code.google.com by blueheyb...@gmail.com on 28 Apr 2009 at 11:16

Attachments: