java - xjc: override xs:simpleType definition -
i compiling set of xsds java classes using xjc
. able override data type definition given simple type. xsd snippet is:
<xs:simpletype name="cpt-datetime"> <xs:annotation> <xs:appinfo>can specified integer number or xs:datetime</xs:appinfo> </xs:annotation> <xs:union membertypes="xs:unsignedlong xs:datetime"/> </xs:simpletype>
which results (not surprisingly) in element of cpt-datetime
type being defined in resulting java class string
, e.g.
public class ccreporttraininitialization { ... @xmlelement(required = true) protected string time; ... public string gettime() { return time; } public void settime(string value) { this.time = value; } ...
what datatype of time
(in example) date-time specific type, e.g. xmlgregoriancalendar
or that:
public class ccreporttraininitialization { ... @xmlelement(required = true) protected xmlgregoriancalendar time; ... public xmlgregoriancalendar gettime() { return time; } public void settime(xmlgregoriancalendar value) { this.time = value; } ...
is possible?
i've been experimenting binding file i'm not sure it's possible do. suggestions?
further options are:
jaxb:basetype
jaxb:javatype
xjc:javatype
-jaxb:javatype
allows specifying adapter class instead ofunmarshal
/marshal
methods.
i argue jaxb:class/@ref
customization not right simple type makes "class" type. matters internal xjc model, of xjc plugins may handle type incorrectly.
i think should use jaxb:javatype
here. try:
<?xml version="1.0" encoding="utf-8"?> <jxb:bindings jxb:version="2.1" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:tns="urn:your-target-namespace"> <jxb:bindings node="/xs:schema" schemalocation="../tcip_4_0_0_final.xsd"> <jxb:globalbindings> <jxb:javatype name="javax.xml.datatype.xmlgregoriancalendar" xmltype="tns:cpt-datetime"/> </jxb:globalbindings> </jxb:bindings> </jxb:bindings>
Comments
Post a Comment