Create an XML Schemas parse context for that memory buffer
       expected to contain an XML Schemas file.
5844
def schemaNewMemParserCtxt(buffer, size):
    
    ret = libxml2mod.xmlSchemaNewMemParserCtxt(buffer, size)
    if ret is None:raise parserError('xmlSchemaNewMemParserCtxt() failed')
    return SchemaParserCtxt(_obj=ret)
166443
@Override
    protected XMLValidationSchema loadSchema(InputSource src, Object sysRef)
        throws XMLStreamException
    {
        /* 26-Oct-2007, TSa: Are sax parser factories safe to share?
         *   If not, should just create new instances for each
         *   parsed schema.
         */
        SAXParserFactory saxFactory = getSaxFactory();

        MyGrammarController ctrl = new MyGrammarController();
        XMLSchemaGrammar grammar = XMLSchemaReader.parse(src, saxFactory, ctrl);
        if (grammar == null) {
            String msg = "Failed to load W3C Schema from '"+sysRef+"'";
            String emsg = ctrl.mErrorMsg;
            if (emsg != null) {
                msg = msg + ": "+emsg;
            }
            throw new XMLStreamException(msg);
        }
        return new W3CSchema(grammar);
    }
904544
private static Schema loadXmlSchema() throws SAXException {

		InputStream schemaFileStream = findFileInClasspath(CONFIG_SCHEMA_FILE_NAME);
		Constraint.ensureNotNull(schemaFileStream, "JCors configuration schema not found");

		SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
		return schemaFactory.newSchema(new StreamSource(schemaFileStream));
	}
772591
private void createSchemaOnDb() {
        StringBuilder sql = new StringBuilder();
        sql.append(topology.getSqlgGraph().getSqlDialect().createSchemaStatement(this.name));
        if (this.sqlgGraph.getSqlDialect().needsSemicolon()) {
            sql.append(";");
        }
        if (logger.isDebugEnabled()) {
            logger.debug(sql.toString());
        }
        Connection conn = this.sqlgGraph.tx().getConnection();
        try (Statement stmt = conn.createStatement()) {
            stmt.execute(sql.toString());
        } catch (SQLException e) {
            logger.error("schema creation failed " + this.sqlgGraph.toString(), e);
            throw new RuntimeException(e);
        }
    }
1160017
def build(_resource, _cache=True, **kwargs):
    
    return _SCHEMAFACTORY.build(_resource=_resource, _cache=True, **kwargs)
86518
def _gen_xml(name,
             cpu,
             mem,
             diskp,
             nicp,
             hypervisor,
             os_type,
             arch,
             graphics=None,
             loader=None,
             **kwargs):
    '''
    
    '''
    mem = int(mem) * 1024  # MB
    context = {
        'hypervisor': hypervisor,
        'name': name,
        'cpu': six.text_type(cpu),
        'mem': six.text_type(mem),
    }
    if hypervisor in ['qemu', 'kvm']:
        context['controller_model'] = False
    elif hypervisor == 'vmware':
        # TODO: make bus and model parameterized, this works for 64-bit Linux
        context['controller_model'] = 'lsilogic'

    # By default, set the graphics to listen to all addresses
    if graphics:
        if 'listen' not in graphics:
            graphics['listen'] = {'type': 'address', 'address': '0.0.0.0'}
        elif 'address' not in graphics['listen'] and graphics['listen']['type'] == 'address':
            graphics['listen']['address'] = '0.0.0.0'

        # Graphics of type 'none' means no graphics device at all
        if graphics.get('type', 'none') == 'none':
            graphics = None
    context['graphics'] = graphics

    if loader and 'path' not in loader:
        log.info('`path` is a required property of `loader`, and cannot be found. Skipping loader configuration')
        loader = None
    elif loader:
        loader_attributes = []
        for key, val in loader.items():
            if key == 'path':
                continue
            loader_attributes.append("{key}='{val}'".format(key=key, val=val))
        loader['_attributes'] = ' '.join(loader_attributes)

    if 'boot_dev' in kwargs:
        context['boot_dev'] = []
        for dev in kwargs['boot_dev'].split():
            context['boot_dev'].append(dev)
    else:
        context['boot_dev'] = ['hd']

    context['loader'] = loader

    if os_type == 'xen':
        # Compute the Xen PV boot method
        if __grains__['os_family'] == 'Suse':
            context['kernel'] = '/usr/lib/grub2/x86_64-xen/grub.xen'
            context['boot_dev'] = []

    if 'serial_type' in kwargs:
        context['serial_type'] = kwargs['serial_type']
    if 'serial_type' in context and context['serial_type'] == 'tcp':
        if 'telnet_port' in kwargs:
            context['telnet_port'] = kwargs['telnet_port']
        else:
            context['telnet_port'] = 23023  # FIXME: use random unused port
    if 'serial_type' in context:
        if 'console' in kwargs:
            context['console'] = kwargs['console']
        else:
            context['console'] = True

    context['disks'] = []
    disk_bus_map = {'virtio': 'vd', 'xen': 'xvd', 'fdc': 'fd', 'ide': 'hd'}
    for i, disk in enumerate(diskp):
        prefix = disk_bus_map.get(disk['model'], 'sd')
        disk_context = {
            'device': disk.get('device', 'disk'),
            'target_dev': '{0}{1}'.format(prefix, string.ascii_lowercase[i]),
            'disk_bus': disk['model'],
            'type': disk['format'],
            'index': six.text_type(i),
        }
        if 'source_file' and disk['source_file']:
            disk_context['source_file'] = disk['source_file']

        if hypervisor in ['qemu', 'kvm', 'bhyve', 'xen']:
            disk_context['address'] = False
            disk_context['driver'] = True
        elif hypervisor in ['esxi', 'vmware']:
            disk_context['address'] = True
            disk_context['driver'] = False
        context['disks'].append(disk_context)
    context['nics'] = nicp

    context['os_type'] = os_type
    context['arch'] = arch

    fn_ = 'libvirt_domain.jinja'
    try:
        template = JINJA.get_template(fn_)
    except jinja2.exceptions.TemplateNotFound:
        log.error('Could not load template %s', fn_)
        return ''

    return template.render(**context)
439408
def schemaParse(self):
        
        ret = libxml2mod.xmlSchemaParse(self._o)
        if ret is None:raise parserError('xmlSchemaParse() failed')
        __tmp = Schema(_obj=ret)
        return __tmp
659178
def create_schema(self):
        """"""
        cursor = self.cursor
        execute = cursor.execute
        execute('SHOW TABLES')
        tables = {table for table, in cursor}
        if 'gauged_data' not in tables:
            execute("""CREATE TABLE gauged_data (
                namespace INT(11) UNSIGNED NOT NULL,
                offset INT(11) UNSIGNED NOT NULL,
                `key` BIGINT(15) UNSIGNED NOT NULL,
                data MEDIUMBLOB NOT NULL,
                flags INT(11) UNSIGNED NOT NULL,
                PRIMARY KEY (offset, namespace, `key`))""")
        if 'gauged_keys' not in tables:
            execute("""CREATE TABLE gauged_keys (
                id BIGINT(15) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
                namespace INT(11) UNSIGNED NOT NULL,
                `key` VARCHAR(255) BINARY NOT NULL,
                UNIQUE KEY (namespace, `key`))""")
        if 'gauged_writer_history' not in tables:
            execute("""CREATE TABLE gauged_writer_history (
                id VARCHAR(255) NOT NULL PRIMARY KEY,
                timestamp BIGINT(15) UNSIGNED NOT NULL)""")
        if 'gauged_cache' not in tables:
            execute("""CREATE TABLE gauged_cache (
                namespace INT(11) UNSIGNED NOT NULL,
                `key` BIGINT(15) UNSIGNED NOT NULL,
                hash BINARY(20) NOT NULL,
                length BIGINT(15) UNSIGNED NOT NULL,
                start BIGINT(15) UNSIGNED NOT NULL,
                value FLOAT(11),
                PRIMARY KEY (namespace, hash, length, start))""")
        if 'gauged_statistics' not in tables:
            execute("""CREATE TABLE gauged_statistics (
                namespace INT(11) UNSIGNED NOT NULL,
                offset INT(11) UNSIGNED NOT NULL,
                data_points INT(11) UNSIGNED NOT NULL,
                byte_count INT(11) UNSIGNED NOT NULL,
                PRIMARY KEY (namespace, offset))""")
        if 'gauged_metadata' not in tables:
            execute("""CREATE TABLE gauged_metadata (
                `key` VARCHAR(255) NOT NULL PRIMARY KEY,
                value VARCHAR(255) NOT NULL)""")
        self.db.commit()
267671
def create_schema(self, schema):
        
        if schema not in self.schemas:
            sql = "CREATE SCHEMA " + schema
            self.execute(sql)
918123
def createDocParserCtxt(cur):
    
    ret = libxml2mod.xmlCreateDocParserCtxt(cur)
    if ret is None:raise parserError('xmlCreateDocParserCtxt() failed')
    return parserCtxt(_obj=ret)
1200124
private SFPair<String, String> applySessionContext(String catalog,
                                                     String schemaPattern)
  {
    if (catalog == null && metadataRequestUseConnectionCtx)
    {
      catalog = session.getDatabase();

      if (schemaPattern == null)
      {
        schemaPattern = session.getSchema();
      }
    }
    return SFPair.of(catalog, schemaPattern);
  }
89154
def _pull_schema_definition(self, fname):
        """"""
        std_url = urlopen(self._ontology_file)
        cached_std = open(fname, "w+")
        cached_std.write(std_url.read())
        cached_std.close()
102004
private byte[] getSchemaBytes() {

        StringBuffer schema = new StringBuffer(512);
        schema.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        schema.append("<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\">");
        Iterator<I_CmsXmlSchemaType> i = m_registeredTypes.values().iterator();
        while (i.hasNext()) {
            I_CmsXmlSchemaType type = i.next();
            schema.append(type.getSchemaDefinition());
        }
        schema.append("</xsd:schema>");
        String schemaStr = schema.toString();

        try {
            // pretty print the XML schema
            // this helps in debugging the auto-generated schema includes
            // since it makes them more human-readable
            Document doc = CmsXmlUtils.unmarshalHelper(schemaStr, null);
            schemaStr = CmsXmlUtils.marshal(doc, CmsEncoder.ENCODING_UTF_8);
        } catch (CmsXmlException e) {
            // should not ever happen
            LOG.error(Messages.get().getBundle().key(Messages.LOG_PRETTY_PRINT_SCHEMA_BYTES_ERROR_0), e);
        }
        if (LOG.isInfoEnabled()) {
            LOG.info(
                Messages.get().getBundle().key(
                    Messages.LOG_XML_TYPE_DEFINITION_XSD_2,
                    CmsXmlContentDefinition.XSD_INCLUDE_OPENCMS,
                    schemaStr));
        }
        try {
            return schemaStr.getBytes(CmsEncoder.ENCODING_UTF_8);
        } catch (UnsupportedEncodingException e) {
            // should not happen since the default encoding of UTF-8 is always valid
            LOG.error(Messages.get().getBundle().key(Messages.LOG_CONVERTING_SCHEMA_BYTES_ERROR_0), e);
        }
        return null;
    }
1336676
public ProcessesXmlParse createParse() {
    ProcessesXmlParse processesXmlParse = new ProcessesXmlParse(this);
    processesXmlParse.setSchemaResource(ReflectUtil.getResourceUrlAsString(PROCESS_APPLICATION_XSD));
    return processesXmlParse;
  }
1362217
private void addZealotXmlInContext() {
        for (String xmlPath: xmlPaths) {
            String nameSpace = XmlNodeHelper.getZealotXmlNameSpace(xmlPath);
            if (StringHelper.isNotBlank(nameSpace)) {
                XmlContext.INSTANCE.add(nameSpace, xmlPath);
            }
        }
    }
912217
def _setup_schema(Base, session):
    """"""

    def create_schema_class(m):
        if hasattr(m, 'send_signalbus_message'):
            # Signal models should not use the SQLAlchemy session.
            class Meta(object):
                model = m
        else:
            class Meta(object):
                model = m
                sqla_session = session

        schema_class_name = '%sSchema' % m.__name__
        return type(schema_class_name, (ModelSchema,), {'Meta': Meta})

    def setup_schema_fn():
        for model in Base._decl_class_registry.values():
            if hasattr(model, '__tablename__'):
                if model.__name__.endswith("Schema"):
                    raise ModelConversionError(
                        'Unexpected model name: "{}". '
                        'For safety, _setup_schema() can not be used when a '
                        'model class ends with "Schema".'.format(model.__name__)
                    )
                schema_class = getattr(model, '__marshmallow__', None)
                if schema_class is None:
                    schema_class = model.__marshmallow__ = create_schema_class(model)
                if hasattr(model, 'send_signalbus_message'):
                    setattr(model, '__marshmallow_schema__', schema_class())

    return setup_schema_fn
1278910
def _loadContext(context, xmlElement, attributeToFormatMap):
    
    attribute = _safeGetRequiredAttribute(xmlElement, 'attribute', '<not set>').lower()
    if attribute != '<not set>':  # there are no attributes for internal contexts, used by rules. See perl.xml
        try:
            format = attributeToFormatMap[attribute]
        except KeyError:
            _logger.warning('Unknown context attribute %s', attribute)
            format = TextFormat()
    else:
        format = None

    textType = format.textType if format is not None else ' '
    if format is not None:
        format = _convertFormat(format)

    lineEndContextText = xmlElement.attrib.get('lineEndContext', '#stay')
    lineEndContext = _makeContextSwitcher(lineEndContextText,  context.parser)
    lineBeginContextText = xmlElement.attrib.get('lineBeginContext', '#stay')
    lineBeginContext = _makeContextSwitcher(lineBeginContextText, context.parser)
    lineEmptyContextText = xmlElement.attrib.get('lineEmptyContext', '#stay')
    lineEmptyContext = _makeContextSwitcher(lineEmptyContextText, context.parser)

    if _parseBoolAttribute(xmlElement.attrib.get('fallthrough', 'false')):
        fallthroughContextText = _safeGetRequiredAttribute(xmlElement, 'fallthroughContext', '#stay')
        fallthroughContext = _makeContextSwitcher(fallthroughContextText, context.parser)
    else:
        fallthroughContext = None

    dynamic = _parseBoolAttribute(xmlElement.attrib.get('dynamic', 'false'))

    context.setValues(attribute, format, lineEndContext, lineBeginContext, lineEmptyContext, fallthroughContext, dynamic, textType)

    # load rules
    rules = _loadChildRules(context, xmlElement, attributeToFormatMap)
    context.setRules(rules)