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";,
  "PurchaseOrder");
SchemaType poElementType =
  schemaTypeLoader.findElement(poElementQName).getType();
String poElementJavaName = poElementType.getFullJavaName();
System.out.println("PurchaseOrder element (root) has signature: " +
  poElementType.toString());
System.out.println("PurchaseOrder element (root) has java class: " +
  poElementJavaName);

Output
======
PurchaseOrder element (root) has signature:
  E=PurchaseOrder|[EMAIL PROTECTED]://javector.com/samples
PurchaseOrder element (root) has java class: null




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

Reply via email to