Hello Stefan ,
 
The org.apache.xmlbeans.impl.tool.SchemaCompiler
not only provides the ability to compile classes ( the default behaviour) but it also produces java source code. you can use the -src [dir] option with scomp to accomplish this.
 
 
For the code perspective, please look at line 829-831 (thats the line numbers being displayed in my editor) of  org.apache.xmlbeans.impl.tool.SchemaCompiler
 
            result &= SchemaCodeGenerator.compileTypeSystem(system, srcDir, javaFiles, sourcesToCopyMap,
                classpath, classesDir, outputJar, nojavac, errorListener, repackage, verbose,
                sourcefiles, schemasDir);
 
 
the actual implementation is at
org.apache.xmlbeans.impl.tool.SchemaCodeGenerator
 
I did a source code generation for the easypo.xsd that is available under
v2/xkit/schemas/easypo.xsd
 
Hope this is useful
Dutta:)
 
 


Stefan.Zauner@gmx.de wrote:

Hi!

It looks like the functionality of this class is to generate clas-files.
At least I noticed that is what scomp does.
The problem is: I nead the generated code.
Does anybody know a way to get it?

Thanks again

Stefan

________________________________

Von: Dutta Satadip [mailto:s-dutta@sbcglobal.net]
Gesendet: Donnerstag, 11. März 2004 07:49
An: xmlbeans-user@xml.apache.org
Cc: Stefan.Zauner@gmx.de
Betreff: Re: dynamic compilation of XMLSchema-files


Hello Stefan,
Please look at the following class.

org.apache.xmlbeans.impl.tool.SchemaCompiler

This is under the v2/src/xmlcomp directory

Although the SchemaComplier class can be run from the command line, I am
sure you can extract the appropriate logic for your needs.

Hopefully this is helpful
With Regards
Dutta:)


Stefan.Zauner@gmx.de wrote:

I'm looking for a tool that is able to create Java-Code out of
XML-Schema-complex/simple-types during the Runtime of a Java-program and
(best case) is able to deliver the results to my application.
More exactly, I want to give a xsd-file to my program which then
should make Java - classes or interfaces out of the complex types or simple
types contained in the schema-file.
Is this possible by the help of XMLBeans?

I already tried to compile a simple xsd-file...


targetNamespace="http://www.w3schools.com
"
xmlns="http://www.w3schools.com "
elementFormDefault="qualified">












...by using the following piece of Java-Code I got from the
XMLBeans-Javadoc-API:

try {
XmlOptions options = new XmlOptions();
options.setCompileNoValidation();

SchemaTypeSystem sts = XmlBeans.compileXsd(new XmlObject[]
{ XmlObject.Factory.parse("testBeans.xsd") },
XmlBeans.getBuiltinTypeSystem(), options);
} catch (XmlException xmle) {
xmle.printStackTrace();
}

But all I get is this exception...

org.apache.xmlbeans.XmlException: error: The markup in the document
preceding the root element must be well-formed.
at
org.apache.xmlbeans.impl.store.Root$SaxLoader.load(Root.java:762)
at org.apache.xmlbeans.impl.store.Root.loadXml(Root.java:1036)
at org.apache.xmlbeans.impl.store.Root.loadXml(Root.java:1028)
at org.apache.xmlbeans.impl.store.Root.loadXml(Root.java:1048)
at
org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderB
ase.java:200)
at org.apache.xmlbeans.XmlObject$Factory.parse(XmlObject.java:502)
at Converter.generateTypesFromSchema(Converter.java:88)
at Converter.convertWSDL(Converter.java:42)
at Reader.getWSDLDocument(Reader.java:51)
at Test.main(Test.java:17)
Caused by: org.xml.sax.SAXParseException: The markup in the document
preceding the root element must be well-formed.
at
org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1213)
at
org.apache.xerces.framework.XMLDocumentScanner.reportFatalXMLError(XMLDocume
ntScanner.java:570)
at
org.apache.xerces.framework.XMLDocumentScanner$XMLDeclDispatcher.dispatch(XM
LDocumentScanner.java:753)
at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
at
org.apache.xmlbeans.impl.store.Root$SaxLoader.load(Root.java:735)
... 9 more

... and I just can't figure out why.
Any hint for me?

Thanks

Stefan



- ---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/