'Import XML data using an XSLT: static/formats/<format>/import.xsl
Setting the source_type is possible'

def import_xml(self, filepath, prefix, resourcename, format, source_type=None):

    prefix = prefix.strip('"    ')
    resourcename = resourcename.strip('"    ')
    errorString = 'prepopulate    error:    file    %s    missing'
    try:
        File = open(filepath, 'r')
    except IOError:
        self.errorList.append((errorString % filepath))
        return
    stylesheet = os.path.join(current.request.folder, 'static', 'formats', format, 'import.xsl')
    try:
        S = open(stylesheet, 'r')
    except IOError:
        self.errorList.append((errorString % stylesheet))
        return
    else:
        S.close()
    tablename = ('%s_%s' % (prefix, resourcename))
    resource = current.s3db.resource(tablename)
    if (tablename not in self.customised):
        customise = current.deployment_settings.customise_resource(tablename)
        if customise:
            request = S3Request(prefix, resourcename, current.request)
            customise(request, tablename)
            self.customised.append(tablename)
    auth = current.auth
    auth.rollback = True
    try:
        resource.import_xml(File, stylesheet=stylesheet, source_type=source_type)
    except SyntaxError as e:
        self.errorList.append(('WARNING:    import    error    -    %s    (file:    %s,    stylesheet:    %s/import.xsl)' % (e, filepath, format)))
        auth.rollback = False
        return
    if (not resource.error):
        current.db.commit()
    else:
        error = resource.error
        self.errorList.append(('%s    -    %s:    %s' % (filepath, tablename, error)))
        errors = current.xml.collect_errors(resource)
        if errors:
            self.errorList.extend(errors)
        current.db.rollback()
    auth.rollback = False
