How can I get JAXB to marshall a string or primitive data type and set the type=”string”, or type=”int” in the resulting XML. I have tried specifying a specific type for each field
@XmlSchemaType(name = "string",namespace = "http://www.w3.org/2001/XMLSchema",type = String.class)
But this makes no difference the resulting XML is without type.
Thanks for reading
Update
this is basically what I have in a JaxB class:
@XmlElement(required = true)
protected Keys keys;
protected String workflowID;
protected String fromFigure;
protected String fromPort;
This is the resulting XML
<keys type="draw2d.ArrayList">
<data type="Array">
<element type="draw2d.FlowConnectionModel">
<workflowID>d8f71b92-dc69-4115-9095-d748265d4e68</workflowID>
<fromFigure>706531d9-cd03-4347-9ba2-d9b525035e0d</fromFigure>
<fromPort>out_right_initialState</fromPort>
Notice that there is a type set for the keys, data and element types but none for the primitive data types of workflowID, fromFigure and fromPort. What I want is this:
<keys type="draw2d.ArrayList">
<data type="Array">
<element type="draw2d.FlowConnectionModel">
<workflowID type="string">d8f71b92-dc69-4115-9095-d748265d4e68</workflowID>
<fromFigure type="string">706531d9-cd03-4347-9ba2-d9b525035e0d</fromFigure>
<fromPort type="string">out_right_initialState</fromPort>
In the end I had to change the schema to use complex types as opposed to simple types.
A snippet from the original schema
Changed to this
With extra complex types
And now I get what I need when marshalling with every type specified.
Thanks for those that responded and read.