xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Don Stewart" <Don.Stew...@corizon.com>
Subject RE: using SchemaType.getFullJavaName with dynamically compiled schema
Date Thu, 08 Sep 2005 09:05:31 GMT

I do just what your asking. I load and parse a schema, generate the
xsb's then for each SchemaType in the typesystem I get the java
After that I load the generated java files using Janino, using the
classloader for java source which compiles them on the fly and then do
some introspection/futher work using the class.

My code is spread across a number of java source file. If you want mail
me offline and I'll see about extracting the code into a mail for you.



-----Original Message-----
From: Mark Hansen [mailto:mark@javector.com] 
Sent: 07 September 2005 18:49
To: user@xmlbeans.apache.org
Subject: using SchemaType.getFullJavaName with dynamically compiled

I would like to do the following:
(1) Compile a schema on the fly using XmlBeans.compileXsd
(2) Inspect the resulting SchemaType instances to get information about
their underlying Java methods so that I can use these methods to
manipulate the instances.

But, it seems that the compileXsd method (below) does not create the
"Java Types Generated from User-Derived Schema" (as defined in
docs/guide/conJavaTypesGeneratedFromUserDerived.html), but only the
SchemaTypeSystem representations.

public static SchemaTypeSystem compileXsd(XmlObject[] schemas,
                                           SchemaTypeLoader typepath,
                                           XmlOptions options)
                                    throws XmlException

It seems that if I want to generate the Java Types, then I would need to
use XmlBeans.compileXmlBeans.  But, in order to use that method, I need
to get an instance of BindingConfig and Filer, which seem to be empty
implementations at this point.

How can I create te Java Types on the fly so that methods such as
SchemaType.getFullJavaName will work?  Right now, these methods always
return null.

My code and sample output are below.

Code Snippet

SchemaTypeSystem schemaTypeSystem = XmlBeans.compileXsd
   (new XmlObject[] {schema}, XmlBeans.getBuiltinTypeSystem(), null);
SchemaTypeLoader schemaTypeLoader = XmlBeans.typeLoaderUnion(
   new SchemaTypeLoader[] { schemaTypeSystem,
     XmlBeans.getBuiltinTypeSystem() });

QName poElementQName = new QName("http://javector.com/samples",
SchemaType poElementType =
String poElementJavaName = poElementType.getFullJavaName();
System.out.println("PurchaseOrder element (root) has signature: " +
System.out.println("PurchaseOrder element (root) has java class: " +

PurchaseOrder element (root) has signature:
PurchaseOrder element (root) has java class: null

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

View raw message