[prev in list] [next in list] [prev in thread] [next in thread]
List: xmlbeans-user
Subject: RE: RE: How to get Java Class of .xsd at runtime dynamically
From: "Radu Preotiuc-Pietro" <radu.preotiuc-pietro () oracle ! com>
Date: 2008-10-24 3:25:48
Message-ID: 20081023202548031.00000005192 () RADUP02
[Download RAW message or body]
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:aliban@gmx.net]
> 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" <radu.preotiuc-pietro@oracle.com>
> > 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: aliban@gmx.net [mailto:aliban@gmx.net]
> > > 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: user-unsubscribe@xmlbeans.apache.org
> > > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > >
> > >
> > >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
>
> --
> 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: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic