parse a schema definition resource and build an internal
           XML Shema struture which can be used to validate instances.
763265
def relaxNGParse(self):
        
        ret = libxml2mod.xmlRelaxNGParse(self._o)
        if ret is None:raise parserError('xmlRelaxNGParse() failed')
        __tmp = relaxNgSchema(_obj=ret)
        return __tmp
954308
private void validate() {
        if (isValid != null) {
            return;
        }

        ParsingValidator v =
            new ParsingValidator(useSchema ? Languages.W3C_XML_SCHEMA_NS_URI
                                 : Languages.XML_DTD_NS_URI);
        List<Source> schemaSourceList = new ArrayList<Source>();
        if (systemId != null) {
            schemaSourceList.add(new StreamSource(systemId));
        }
        addSchemaSources(schemaSource, schemaSourceList);
        v.setSchemaSources(schemaSourceList.toArray(new Source[0]));

        try {
            ValidationResult r =
                v.validateInstance(new SAXSource(validationInputSource));
            isValid = r.isValid() ? Boolean.TRUE : Boolean.FALSE;
            for (ValidationProblem p : r.getProblems()) {
                validationProblem(p);
            }
        } catch (org.xmlunit.ConfigurationException e) {
            throw new ConfigurationException(e.getCause());
        } catch (org.xmlunit.XMLUnitException e) {
            throw new XMLUnitRuntimeException(e.getMessage(), e.getCause());
        }

        if (usingDoctypeReader && isValid == Boolean.FALSE) {
            try {
                messages.append("\nContent was: ")
                    .append(getOriginalContent(validationInputSource));
            } catch (IOException e) {
                // silent but deadly?
            }
        }
    }
1272714
private String parse(DocumentContext document) throws ParseException {
    if (document.namespaceDeclaration() != null) {
      setCurrentNamespace(
        document.namespaceDeclaration().qualifiedIdentifier().value);
    } else {
      setCurrentNamespace("");
    }

    setCurrentImports(document.importDeclarations());
    NamedDataSchema schema = parseNamedType(document.namedTypeDeclaration());
    topLevelSchemas.add(schema);
    return schema.getFullName();
  }
287849
def build_collection_schema(**args)
      object.map { |object| self.class.new(object, context).build_schema(args) }
    end
1121728
def add_schema(self, schema):
        

        # serialize instances of SchemaNode before parsing
        if isinstance(schema, SchemaNode):
            schema = schema.to_schema()

        for subschema in self._get_subschemas(schema):
            # delegate to SchemaType object
            schema_generator = self._get_generator_for_schema(subschema)
            schema_generator.add_schema(subschema)

        # return self for easy method chaining
        return self
813632
@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.
         */
        /* Another thing; should we use a controller to get notified about
         * errors in parsing?
         */
        SAXParserFactory saxFactory = getSaxFactory();
        MyGrammarController ctrl = new MyGrammarController();
        TREXGrammar grammar = RELAXNGReader.parse(src, saxFactory, ctrl);
        if (grammar == null) {
            String msg = "Failed to load RelaxNG schema from '"+sysRef+"'";
            String emsg = ctrl.mErrorMsg;
            if (emsg != null) {
                msg = msg + ": "+emsg;
            }
            throw new XMLStreamException(msg);
        }
        return new RelaxNGSchema(grammar);
    }
202886
def compile_swagger_schema(schema_dir, resource_listing):
    
    mapping = build_schema_mapping(schema_dir, resource_listing)
    resource_validators = ingest_resources(mapping, schema_dir)
    endpoints = list(build_swagger_12_endpoints(resource_listing, mapping))
    return SwaggerSchema(endpoints, resource_validators)
629373
protected String readSchemaDefinition(String schemaUri) throws CmsRuntimeException {

        // the schema definition is located in a separate file for easier editing
        String schemaDefinition;
        try {
            schemaDefinition = CmsFileUtil.readFile(schemaUri, CmsEncoder.ENCODING_UTF_8);
        } catch (Exception e) {
            throw new CmsRuntimeException(
                Messages.get().container(Messages.ERR_XMLCONTENT_LOAD_SCHEMA_1, schemaUri),
                e);
        }
        return schemaDefinition;
    }
884795
def validate(instance):
    

    jsonschema.validate(
        to_dict(instance, dict_type=dict), build_schema(instance.__class__)
    )
971237
def _build_schema(self, s):
        
        w = self._whatis(s)
        if w == self.IS_LIST:
            w0 = self._whatis(s[0])
            js = {"type": "array",
                  "items": {"type": self._jstype(w0, s[0])}}
        elif w == self.IS_DICT:
            js = {"type": "object",
                  "properties": {key: self._build_schema(val) for key, val in s.items()}}
            req = [key for key, val in s.items() if not val.is_optional]
            if req:
                js["required"] = req
        else:
            js = {"type": self._jstype(w, s)}
        for k, v in self._json_schema_keys.items():
            if k not in js:
                js[k] = v
        return js
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));
	}
873753
def resource(name)
      if @schema['definitions'].has_key?(name)
        ResourceSchema.new(@schema, name)
      else
        raise SchemaError.new("Unknown resource '#{name}'.")
      end
    end
1156908
def build_schema(
    source: Union[str, Source],
    assume_valid=False,
    assume_valid_sdl=False,
    no_location=False,
    experimental_fragment_variables=False,
) -> GraphQLSchema:
    """"""
    return build_ast_schema(
        parse(
            source,
            no_location=no_location,
            experimental_fragment_variables=experimental_fragment_variables,
        ),
        assume_valid=assume_valid,
        assume_valid_sdl=assume_valid_sdl,
    )
109591
def validate(self, schema_str, xml_valid):
        
        # TODO: be able to get doc for error given an xsd.
        # Changed path to allow have xsd that are imported by others xsd in the
        # same library, and not call to SAT page each time that is generated
        # a new XML.
        with change_path():
            path = os.path.join(
                os.path.dirname(os.path.realpath(__file__)), 'templates')
            os.chdir(path)
            schema_root = etree.parse(StringIO(schema_str))
            schema = etree.XMLSchema(schema_root)
        try:
            tree = etree.parse(StringIO(xml_valid.encode('UTF-8')))
            schema.assertValid(tree)
        except etree.DocumentInvalid as ups:
            self.ups = ups
        finally:
            if self.ups:
                self.valid = False
            else:
                self.valid = True
            return self.valid
47771
function parseProperties(source, baseDirectory) {
  // Get the raw SCSS concrete syntax tree.
  const rawTree = parseCSS(source);
  removeWhitespace(rawTree);

  // Convert the concrete syntax tree into a more convenient AST.
  let schema
  const rootRules = []
  for (const rule of rawTree.value) {
    if (rule.type === 'atrule') {
      removeWhitespace(rule);
      const [keyword, argument] = rule.value;
      if (keyword.value === 'schema') {
        schema = visitSchema(argument, baseDirectory)
      } else if (keyword.value === 'import') {
        rootRules.push(...visitImport(argument, baseDirectory))
      }
    } else {
      rootRules.push(visitRule(rule, false))
    }
  }

  // Flatten out any nested selectors.
  const rules = []
  for (const rootRule of rootRules) {
    flattenRule(rootRule, rules, [[]]);
  }

  const validator = new Validator();

  for (const rule of rules) {
    // Validate each rule's properties against the schema.
    for (const property in rule.properties) {
      if (schema) {
        const propertySchema = schema[property]
        const value = rule.properties[property]
        if (!propertySchema) {
          throw new Error(`Property '${property}' is not present in the schema`);
        }
        const {errors} = validator.validate(value, propertySchema);
        if (errors.length > 0) {
          throw new Error(`Invalid value '${value}' for property '${property}'`)
        }
      }
    }

    rule.selectors = rule.selectors.map(applyPseudoClasses)
  }

  return rules;
}
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);
    }
618303
def read_yaml(yaml_data, schema):
    
    try:
        resource = resource_stream('atomic_reactor', schema)
        schema = codecs.getreader('utf-8')(resource)
    except (IOError, TypeError):
        logger.error('unable to extract JSON schema, cannot validate')
        raise

    try:
        schema = json.load(schema)
    except ValueError:
        logger.error('unable to decode JSON schema, cannot validate')
        raise
    data = yaml.safe_load(yaml_data)
    validator = jsonschema.Draft4Validator(schema=schema)
    try:
        jsonschema.Draft4Validator.check_schema(schema)
        validator.validate(data)
    except jsonschema.SchemaError:
        logger.error('invalid schema, cannot validate')
        raise
    except jsonschema.ValidationError:
        for error in validator.iter_errors(data):
            path = "".join(
                ('[{}]' if isinstance(element, int) else '.{}').format(element)
                for element in error.path
            )

            if path.startswith('.'):
                path = path[1:]

            logger.error('validation error (%s): %s', path or 'at top level', error.message)

        raise

    return data