I've been playing around with ways to avoid having to repeatedly parse large
schema where the performance isn't great. The scenario is that I have a base
set of types from a schema that I need (e.g. WSDL schema) and a variable set
of types from some user defined schema. So each time I want a DataFactory
containing my set of types I need to use XSDHelper::define for the wsdl
schema then XSDHelper::define for the user schema.

What I'd like to do is to  parse the WSDL once with XSDHelper::define then
be able to extract the Types and Properties, add them to a new XSDHelper and
then add my extra types. This can nearly be achieved in the current code by
cloning the underlying DataFactory:

XSDHelperPtr wsdlHelper = HelperProvider::getXSDHelper();
wsdlHelper->define(".....wsdl.xsd");

...

DataFactoryPtr myDF = wsdlHelper->getDataFactory()->clone();
XSDHelperPtr myHelper = HelperProvider::getXSDHelper(myDF);

The problem with this is that the current implementation of clone copies the
Types and Properties but loses the additional schema inforamation (such as
is the property an element or an attribute). This could be fixed by moving
all the schema information down in to the Type and Property definitions,
which is where I think it should ultimately end up, but this is a BIG
change.

A much simpler solution would be to cache the parsed TypeDefinitions in the
XSDHelper and add a new method to retrieve these. There is a public method
today on XSDHelper, though I think it is only used internally after the
TypeDefinitions object is retrieved from the SchemaParser:

SDO_API virtual void defineTypes(TypeDefinitions& types) = 0;

Today the "types" passed in are used to call AddType, AddPropertyToType etc.
on the DataFactory... and are then destroyed. If we cache the
TypeDefinitions in the XSDHelper we can add

SDO_API virtual TypeDefinitions& getDefinedTypes() = 0;

to retrieve the parsed types. So now I can do:


XSDHelperPtr myHelper = HelperProvider::getXSDHelper();
myHelper->defineTypes(wsdlHelper->getDefinedTypes());

which creates a new XSDHelper and DataFactory containing the Types and
Properties from the wsdlHelper + all the schema information (which is held
in the TypeDefinitions).

This is a fairly simple change to make.

Cheers,

--
Pete

Reply via email to