'@param root: The xml root.
@type root: L{sax.element.Element}
@param baseurl: The base url used for importing.
@type baseurl: basestring
@param options: An options dictionary.
@type options: L{options.Options}
@param container: An optional container.
@type container: L{SchemaCollection}'

def __init__(self, root, baseurl, options, container=None):

    self.root = root
    self.id = objid(self)
    self.tns = self.mktns()
    self.baseurl = baseurl
    self.container = container
    self.children = []
    self.all = []
    self.types = {}
    self.imports = []
    self.elements = {}
    self.attributes = {}
    self.groups = {}
    self.agrps = {}
    if (options.doctor is not None):
        options.doctor.examine(root)
    form = self.root.get('elementFormDefault')
    if (form is None):
        self.form_qualified = False
    else:
        self.form_qualified = (form == 'qualified')
    if (container is None):
        self.build()
        self.open_imports(options)
        log.debug('built:\n%s', self)
        self.dereference()
        log.debug('dereferenced:\n%s', self)
