<complexType name="spThread">
<sequence>
<element name="SPThreadID" type="int" />
<element name="durtime" minOccurs="0" default="0">
<simpleType>
<restriction base="int">
<minInclusive value="0" />
</restriction>
</simpleType>
</element>
<element name="minexecutions" minOccurs="0" default="0">
<simpleType>
<restriction base="int">
<minInclusive value="0" />
</restriction>
</simpleType>
</element>
<element name="numThreads" type="int" />
<element name="procedures" type="spm:procedure" minOccurs="1"
maxOccurs="unbounded" />
</sequence>
</complexType>
i want to generate this type of .xsd file using java code..? How can i do that.?
Specially how to generate Simple type elements and put restrictions on it ?
Instead of creating your own simple type to represent integers starting with
0, you could leverage the existingxs:nonNegativeIntegertype. I’ll demonstrate with an example.SpThread
You can use the
@XmlSchemaTypeannotation to specify what type should be generated in the XML schema for a field/property.Demo
You can use the
generateSchemamethod onJAXBContextto generate an XML schema:Output
Below is the XML schema that was generated.