<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>I was able to change Python validators, and the new one validates
      with XMLSpy converted schemas!  Woohoo!</p>
    <p>Here's the main test script that I use, which I will check in:</p>
    <p><br>
    </p>
    <p><span style="font-family:monospace"><span
          style="color:#000000;background-color:#ffffff;">import os
        </span><br>
        from jschon import create_catalog, JSON, JSONSchema
        <br>
        import json
        <br>
        <br>
        create_catalog('2020-12')
        <br>
        <br>
        # validate the X3D Resources examples with draft 2020-12 JSON
        schema
        <br>
        # validate one instance "instance" against X3D JSON Schema 4.0
        <br>
        <br>
        class ValidateX3DJSON:
        <br>
           # load a JSON file called jsonname into obj
        <br>
        <br>
           def load_json(self, jsonpre, jsonname):
        <br>
               try:
        <br>
                   with open(jsonname, 'r') as jsonfile:
        <br>
                       obj = json.load(jsonfile)
        <br>
                       jsonfile.close()
        <br>
                       return obj
        <br>
               except:
        <br>
                   print(f"{jsonpre}JsonInvalid", end=" ")
        <br>
                   return None
        <br>
        <br>
           # validate instance against two schemas
        <br>
           def validate_with_schemas(self, entryPath, schemas, pres):
        <br>
               result = [ "jsonSkipped", "jwcSkipped", "dbSkipped"]
        <br>
        <br>
               try:
        <br>
                   result[0] = "jsonDidNotParse"
        <br>
                   instance = JSON(self.load_json("x3d", entryPath))
        <br>
                   result[0] = "jsonParsed"
        <br>
                   for si in range(len(schemas)):
        <br>
                       result[si+1] = pres[si]+"Invalid"
        <br>
                       schemas[si].evaluate(instance)
        <br>
                       result[si+1] = pres[si]+"Valid"
        <br>
               except:
        <br>
                   pass
        <br>
               print(result[0], result[1], result[2], end=" ")
        <br>
        <br>
           def fileList(self, dirpath):
        <br>
               for base, directories, filenames in
        list(os.walk(dirpath)):
        <br>
                   for filename in filenames:
        <br>
                       if filename.endswith(".json"):
        <br>
                           fullpath = os.path.join(base, filename)
        <br>
                           yield fullpath
        <br>
        <br>
        <br>
        <br>
        if __name__ == "__main__":
        <br>
           X3DJSONValidator = ValidateX3DJSON()
        <br>
           pre = ["jwc", "db"]
        <br>
           metaschema = JSONSchema(X3DJSONValidator.load_json("meta",
        "../schema/2020-12-JSONSchema.json"))
        <br>
           schemafiles = ('../schema/x3d-4.0-JSONSchema.json',
        '../schema/X3dXml4.0SchemaConvertedToJson2020-12Schema.json')
        <br>
           schemas = []
        <br>
           for s in range(len(schemafiles)):
        <br>
       schemas.append(JSONSchema(X3DJSONValidator.load_json(pre[s],
        schemafiles[s])))
        <br>
               metaschema.evaluate(schemas[s])
        <br>
           for entryPath in
X3DJSONValidator.fileList("/c/x3d-code/www.web3d.org/x3d/content/examples"):<br>
               X3DJSONValidator.validate_with_schemas(entryPath,
        schemas, pre)
        <br>
               print(entryPath)<br>
      </span></p>
  </body>
</html>