scomp - Compile XML Schema to Java Data Types

Q

How to use the "scomp" command to Compile XML Schema to Java Data Types? I have XMLBeans-2.6.0.zip installed.

✍: FYIcenter.com

A

If you have XMLBeans-4.5.3.zip installed, you can follow this tutorial to run the "xcomp" command to Compile XML Schema to Java Data Types:

1. Run "scomp" command to its options:

\fyicenter\xmlbeans-2.6.0>.\bin\scomp.cmd

Compiles a schema into XML Bean classes and metadata.
Usage: scomp [opts] [dirs]* [schema.xsd]* [service.wsdl]* [config.xsdconfig]*
Options include:
    -cp [a;b;c] - classpath
    -d [dir] - target binary directory for .class and .xsb files
    -src [dir] - target directory for generated .java files
    -srconly - do not compile .java files or jar the output.
    -out [xmltypes.jar] - the name of the output jar
    -dl - permit network downloads for imports and includes (default is off)
    -noupa - do not enforce the unique particle attribution rule
    -nopvr - do not enforce the particle valid (restriction) rule
    -noann - ignore annotations
    -novdoc - do not validate contents of <documentation>
    -noext - ignore all extension (Pre/Post and Interface) found in .xsdconfig files
    -compiler - path to external java compiler
    -javasource [version] - generate java source compatible for a Java version (1.4 or 1.5)
    -ms - initial memory for external java compiler (default '8m')
    -mx - maximum memory for external java compiler (default '256m')
    -debug - compile with debug symbols
    -quiet - print fewer informational messages
    -verbose - print more informational messages
    -version - prints version information
    -license - prints license information
    -allowmdef "[ns] [ns] [ns]" - ignores multiple defs in given namespaces (use ##local for no-namespace)
    -catalog [file] -  catalog file for org.apache.xml.resolver.tools.CatalogResolver. 

2. Run "scomp" command to XML Schema as input and JAR file as output:

\fyicenter\xmlbeans-2.6.0>.\bin\scomp -out easypo.jar schemas\easypo.xsd

Time to build schema type system: 0.39 seconds
Time to generate code: 0.125 seconds
java.io.IOException: Cannot run program "C:\fyicenter\xmlbeans-2.6.0\javac": 
   CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessBuilder.start(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at org.apache.xmlbeans.impl.tool.CodeGenUtil.externalCompile(CodeGenUtil.java:231)
        at org.apache.xmlbeans.impl.tool.SchemaCompiler.compile(SchemaCompiler.java:1154)
        at org.apache.xmlbeans.impl.tool.SchemaCompiler.main(SchemaCompiler.java:373)
        ... 6 more
BUILD FAILED

Too bad. The "scomp" command failed to invoke "javac" compiler. See the next tutorial on how to avoid this problem.

 

SchemaCompiler - Call XML Schema Compiler Directly

easypo.xsd - Purchase Order Test XML Schema

Using Apache XMLBeans in Java Programs

⇑⇑ FAQ for Apache XMLBeans JAR Library

2017-07-07, 3577🔥, 0💬