{
//testing static SDO with XSD Model being contained in a Dynamic SDO not having an XSD Model.
//the schema must be generated with imports / includes for the XSD corresponding to the static
//sdo types.
TypeHelper typeHelper = hc.getTypeHelper();
XSDHelper xsdHelper = hc.getXSDHelper();
SimpleFactory.INSTANCE.register(hc);
DataObject quoteSDO = (DataObject)SimpleFactory.INSTANCE.createQuote();
DataObject quoteType = DataFactory.INSTANCE.create("commonj.sdo", "Type");
quoteType.set("uri", "http://www.example.com/dynamic");
quoteType.set("name", "DynamicQuote");
DataObject aProperty = quoteType.createDataObject("property");
aProperty.set("name", "symbol");
aProperty.set("type", typeHelper.getType("commonj.sdo", "String"));
aProperty = quoteType.createDataObject("property");
aProperty.set("name", "price");
aProperty.set("type", typeHelper.getType("commonj.sdo", "Decimal"));
aProperty = quoteType.createDataObject("property");
aProperty.set("name", "volume");
aProperty.set("type", typeHelper.getType("commonj.sdo", "Double"));
aProperty = quoteType.createDataObject("property");
aProperty.set("name", "containedQuotes");
aProperty.set("type", typeHelper.getType(quoteSDO.getType().getURI(), quoteSDO.getType().getName()));
aProperty.set("containment", new Boolean(true));
aProperty = quoteType.createDataObject("property");
aProperty.set("name", "referredQuotes");
aProperty.set("type", typeHelper.getType(quoteSDO.getType().getURI(), quoteSDO.getType().getName()));
typeHelper.define(quoteType);
Type dynamicQuoteType =
typeHelper.getType("http://www.example.com/dynamic", "DynamicQuote");
Vector types = new Vector();
types.add(dynamicQuoteType);
String xsd = null;
try
{
Hashtable schemaLocationMap = new Hashtable();
schemaLocationMap.put("http://www.example.com/simple", "http://www.example.com/simple/xsd");
xsd = xsdHelper.generate(types, schemaLocationMap);
//System.out.println(xsd);
}
catch ( IllegalArgumentException e )
{
}