Well, this is somewhat a Java question also. Each Java class has to have a 
classloader associated to it. The only way to get a Java class is to have a 
classloader that is able to find the .class representation of a class and load 
it.

What this means for XMLBeans is that you need to compile the Schemas to Java 
source (XmlBeans.compileXsd() or call "scomp" in a different process), then 
compile and jar that source and then create a classloader that has access to 
the freshly created .jar file. XmlBeans can't create classes without source 
.java files and .jar files.

What I should also point out is that you will only be able to use such 
dynamically generated classes via reflection (since they don't exist when your 
code is compiled), so this is why most people prefer to use DOM or XmlCursor 
when dealing with Schemas that they only know about at runtime. The XML 
documents themselves will still be bound to a Schema, so you'll be able to do 
Schema validation on them and get the actual Schema types.

Radu

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, October 08, 2008 2:23 AM
> To: [email protected]
> Subject: How to get Java Class of .xsd at runtime dynamically 
> on-the-fly?
> 
> Hello,
> 
> I need the (freshly compiled?) Java Class from a .xsd at 
> runtime on-the-fly. Without creating java source code files 
> or .jar files.
> 
> I tried org.apache.xmlbeans.XmlBeans.compileXsd()
> and
> org.apache.xmlbeans.XmlBeans.loadXsd()
> 
> but I could not figure out how to spawn a Class from it. I 
> tried to use the SchemaTypeSystem.getClassLoader() but this 
> returns null always. I also tried SchemaType.getJavaClass() 
> but somehow it does not work/I don't understand it/I don't 
> know how to find the "root item Class" with it.
> 
> Can you tell me: how do I get the Java Class of the "root 
> item" within the .xsd at runtime (on-the-fly, without 
> generating code files or .jar) ?
> 
> regards!
> 
> ali
> --
> Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten 
> Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to