Tuesday, August 20, 2013

Convert XSD file to JAR by one command



What is XSD ....??

It is considered as the grammar of the XML... The XML Schema language is also referred to as XML Schema Definition (XSD). Simply XSD files are used to validate XML.


XSD files can be converted to a JAR file simply using the Apache XMLBeans

If you have already setup Apache XMLBeans then go to the folder which contains the xsd file and apply the below command which will convert xsd file to a jar file. (if not follow the Setup XMLBeans instructions)

>> scomp -out <jar_file_name.jar> <xsd_document_name.xsd>

example:
>> scomp -out getSupplierNames.jar getSupplierNames.xsd

Setup XMLBeans

First you have to setup Apache Ant and JDK 1.4 or later version.

JDK installation...
JDK can be downloaded from Java downloads. Install it and set the Environment Variables if they are not set correctly (Right click My Computer --> Properties --> Advanced --> Environment Variables --> System Variables)
    Variable: JAVA_HOME
    Value   : <folder where the JDK software is located>

If PATH variale exists append the value, else add the value.
    Variable: PATH
    Value   : %JAVA_HOME%\bin

Apache Ant installation...
Apache Ant can be downloaded from Ant Binary Distributions. Download the zip file and extract it.
Set below Environment Variables as described above.
    Variable: ANT_HOME
    Value   : <folder where you uncompressed Ant to>


If PATH variale exists append the value, else add the value.
    Variable: PATH
    Value   : %ANT_HOME%/bin

Apache XMLBeans installation...
 Apache XMLBeans can be downloaded from download mirrors. Download the zip file and extract it.
Set below Environment Variables as described earlier.
    Variable: XMLBEANS_HOME
    Value   : <folder where you uncompressed XMLBeans to>


If PATH variale exists append the value, else add the value.
    Variable: PATH
    Value   : %XMLBEANS_HOME%\bin

If CLASSPATH variale exists append the value, else add the value.
    Variable: CLASSPATH
    Value   : <path to xbean.jar>
              [usually this should be %XMLBEANS_HOME%\xbean.jar]

Now all the setup processes are completed and you can convert XSD files to JAR files using the scomp command as described at the top of the article....

CHEERS.......!!