xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Hansen <m...@javector.com>
Subject using SchemaType.getFullJavaName with dynamically compiled schema
Date Wed, 07 Sep 2005 17:48:30 GMT
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

View raw message