Yeah, keep in mind that there can be multiple root elements in a Schema, so use SchemaTypeSystem.documentTypes() to enumerate all of them on the SchemaTypeSystem object returned from compileXmlBeans.
Radu > -----Original Message----- > From: Julian Kölle [mailto:[EMAIL PROTECTED] > Sent: Thursday, October 23, 2008 2:22 AM > To: user@xmlbeans.apache.org > Subject: Re: RE: How to get Java Class of .xsd at runtime > dynamically on-the-fly? > > Hi again, > > I have another question: when XML Beans creates the java > source files with a .xsd, is it possible to identify/know the > java class name of the root element defined int the XML > Schema? Because I must load this class at runtime i must know > its name. Can you point me to a solution for this? > > regards > > > -------- Original-Nachricht -------- > > Datum: Tue, 21 Oct 2008 17:52:00 -0700 > > Von: "Radu Preotiuc-Pietro" <[EMAIL PROTECTED]> > > An: "user@xmlbeans.apache.org" <user@xmlbeans.apache.org> > > Betreff: RE: How to get Java Class of .xsd at runtime > dynamically on-the-fly? > > > 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: user@xmlbeans.apache.org > > > 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] > > -- > GMX Kostenlose Spiele: Einfach online spielen und Spaß haben > mit Pastry Passion! > http://games.entertainment.gmx.net/de/entertainment/games/free > /puzzle/6169196 > > --------------------------------------------------------------------- > 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]