Loading Dependent XSDs in Oracle through Python
1 min read

Loading Dependent XSDs in Oracle through Python

Loading Dependent XSDs in Oracle through Python

One essential feature is that schemas can refer to other schemas. Oracle supports it via the schemaURL parameter. In other words, the url of the referred schema must be the same as the schemaURL parameter used to register the referred schema.

One consequence of this feature is the necessity to provide a load order of schemas. In my case, The order would look like this:

schema_order = [

The loader segment would be something similar to:

for xsd_file in schema_order:
    xsd_path = os.path.join(args.dir, xsd_file)

    # DEBUG
    print "Insert [%s] schema" % xsd_file
    xsd_content = open(xsd_path).read()

    insert_str = INSERT_STR % \
            'name': xsd_file,
            'content': xsd_content,


This is all trivial, except the INSERT_STR. A simple sample would be:

    schemaURL => '%(name)s',
    schemaDoc => %(content)s,
    local => true,
    genTypes => false,
    genTables => true,
    enableHierarchy => dbms_xmlschema.ENABLE_HIERARCHY_NONE

Note: Please refer to the previous article to see e.g. connection setup via cx_oracle.