xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dutta Satadip <s-du...@sbcglobal.net>
Subject Re: dynamic compilation of XMLSchema-files
Date Thu, 11 Mar 2004 06:48:52 GMT
Hello Stefan,
Please look at the following class.
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

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
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...
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  <xs:element name="note">
     <xs:element name="to" type="xs:string"/>
     <xs:element name="from" type="xs:string"/>
     <xs:element name="heading" type="xs:string"/>
     <xs:element name="body" type="xs:string"/>
...by using the following piece of Java-Code I got from the XMLBeans-Javadoc-API:
try {
    XmlOptions options = new XmlOptions();
    SchemaTypeSystem sts = XmlBeans.compileXsd(new XmlObject[]
        { XmlObject.Factory.parse("testBeans.xsd") },
        XmlBeans.getBuiltinTypeSystem(), options);
} catch (XmlException xmle) {
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(SchemaTypeLoaderBase.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(XMLDocumentScanner.java:570)
 at org.apache.xerces.framework.XMLDocumentScanner$XMLDeclDispatcher.dispatch(XMLDocumentScanner.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?

View raw message