xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <da...@coredevelopers.net>
Subject Re: AW: dynamic compilation of XMLSchema-files
Date Mon, 15 Mar 2004 19:23:46 GMT
If you give the schema compiler the right flags it will only generate  
the classes, not compile them.  For one way to do this (with much more  
complication than you might need) you could look at the geronimo  
xmlbeans maven plugin.

http://cvs.apache.org/viewcvs.cgi/incubator-geronimo/modules/maven- 
xmlbeans-plugin/src/java/org/apache/geronimo/tools/xmlbeans/ 
SchemaCompilerWrapper.java

(this uses a slightly modified version of SchemaCompiler)

BTW, is xmlbeans interested in hosting this plugin? I got no response  
the last time I asked.

thanks
david jencks


On Monday, March 15, 2004, at 01:09 AM, <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...
> 	
> 	<?xml version="1.0"?>
> 	<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema
> <http://www.w3.org/2001/XMLSchema> "
> 	    targetNamespace="http://www.w3schools.com
> <http://www.w3schools.com/> "
> 	    xmlns="http://www.w3schools.com <http://www.w3schools.com/> "
> 	    elementFormDefault="qualified">
> 	  <xs:element name="note">
> 	    <xs:complexType>
> 	      <xs:sequence>
> 	     <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"/>
> 	      </xs:sequence>
> 	    </xs:complexType>
> 	  </xs:element>
> 	</xs:schema>
> 	
> 	...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(SchemaTypeLo 
> aderB
> 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(XMLD 
> ocume
> ntScanner.java:570)
> 	 at
> org.apache.xerces.framework.XMLDocumentScanner$XMLDeclDispatcher.dispat 
> ch(XM
> LDocumentScanner.java:753)
> 	 at
> org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentSca 
> nner.
> 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/
>


- ---------------------------------------------------------------------
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/


Mime
View raw message