From SpectLog
Jump to: navigation, search

Generate XSD from XML

According to samples googled on Internet, generating XSD from XML is supposed to be done this way:

inst2xsd -outDir schema -outPrefix example.xsd example.xml

However, the script inst2xsd did not work. Instead of using it, the generator can be called directly:

java -cp /usr/share/java/xmlbeans/xbean.jar org.apache.xmlbeans.impl.inst2xsd.Inst2Xsd -outDir schema -outPrefix example.xsd example.xml

Fix XSD schema

As soon as schema is generated in schema directory, some fixes may be required. For example, if multiple XSD files are generated, some may need to be included in others:

<xs:import namespace="" schemaLocation="example.xsd"/>

Generate Java classes

xjc schema/ -readOnly -d generated/