<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Here's the checked in version of the script...no errors in the
      300 tests I ran?  ?????</p>
    <p><a class="moz-txt-link-freetext" href="https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/python/testjschon.py">https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/python/testjschon.py</a></p>
    <p>Don't forget to <br>
    </p>
    <p>```</p>
    <p>$ source venv/bin/activate</p>
    <p>```</p>
    <p>John<br>
    </p>
    <div class="moz-cite-prefix">On 10/29/21 23:44, John Carlson wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:f711e787-b4c4-4345-060d-d1eb9565e4c5@gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <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>
    </blockquote>
  </body>
</html>