I have the elements to create XSD in the DB. such as a
sample row would be..
XSD_TAG XSD_DATATYPE TYPEDEF MAXBOUND MINBOUND PARENT
reject string basic null null sources
so basically says that one of the tags to be constructed would be reject and it is of type string.
the resulting tag after construction of the xsd should be
<xs:element name="reject" type="xs:string" nillable="true"/>
and since it has a parent tag sources
<xs:complexType name="sources">
<xs:sequence>
<xs:element name="reject" type="xs:string" nillable="true"/>
</xs:sequence>
</xs:complexType>
The header of the xsd should be generated as follows:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xs:schema xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"
jxb:version="1.0">
</xs:schema>
In order to fetch the element name or the Complex type name, a Java bean is used with appropriate getters and setters.
So since the complete structure of the xsd is stored in DB, by getting the List of that bean, we can fetch each element and its properties to be constructed.
The Bean has the following elements mapping to the table columns.
public class TestXsdTable extends HrdhDatedEntry {
/**
*/
private static final long serialVersionUID = -193670018802945645L;
@NotEmpty
@Size(max = ValidationConstants.MAX_LENGTH_20)
private String cJobNm;
@Size(max = ValidationConstants.MAX_LENGTH_20)
private String dbFieldName;
@Size(max = ValidationConstants.MAX_LENGTH_20)
private String colDatType;
private String xsdDoc;
@Size(max = ValidationConstants.MAX_LENGTH_20)
private String xsdTag;
@Size(max = ValidationConstants.MAX_LENGTH_30)
private String xsdDataType;
@Size(max = ValidationConstants.MAX_LENGTH_30)
private String xsdDefVal;
@Size(max = ValidationConstants.MAX_LENGTH_15)
private String typedef;
@Size(max = ValidationConstants.MAX_LENGTH_10)
private String maxbound;
@Size(max = ValidationConstants.MAX_LENGTH_10)
private String minbound;
@Size(max = ValidationConstants.MAX_LENGTH_1)
private String isnillable;
@Size(max = ValidationConstants.MAX_LENGTH_1)
private String isparent;
@Size(max = ValidationConstants.MAX_LENGTH_50)
private String parent;
private String xsdView;
with appropriate getters and setters.
How can I get the structure of the xsd as I described above.
<xs:schema xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" jxb:version="1.0">
<xs:complexType name="sources">
<xs:sequence>
<xs:element name="reject" type="xs:string" nillable="true"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
I tried so many approaches but am not able to get this structure printed. Please guide me. so basically the method should take the java object and retrieve the values to build the xsd.
Please advice.