<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>A friend wrote a loop to generate versions of X3D JSON Schemas.
He wrote the loop in python. I have modified the loop to create
schema validators in python. The code and products are checked
into X3DJSONLD/src/main/python. There are examples of using python
scripts generated from the validator for 3.3 and 4.0.</p>
<p>If someone would like to, they can develop a script for Command
Prompt or PowerShell based on this python script. I don't know
if python on windows does any mapping from Linux to Windows.<br>
</p>
<p>You will need to install fastjsonschema first. pip3 comes with
python3:</p>
<p><br>
</p>
<p>$ pip3 install fastjsonschema</p>
<p>And install jsonlint (use your favorite node.js package manager)
for pretty printing:</p>
<p><span>
<pre><code>$ npm install jsonlint -g
</code></pre>
</span></p>
<p>You may have better results using the schema validator directly
as far as getting good error messages. I haven't figured out how
to do that yet (exercise left to the reader). Right now, the
python validators throws an ugly python error when running python
(of course, to be expected).<br>
</p>
<p><br>
</p>
<p>What I have shown is the generated schemas pass draft-07 built
into a potential build script, and potential for speeding up
python X3D JSON validation.</p>
<p><br>
</p>
<p>I know it's very complex, but *well documented* I think.</p>
<p>I am mainly sending a link due to various mail filters messing up
filenames with embedded host names. Here's the code:<br>
</p>
<p><a class="moz-txt-link-freetext" href="https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/python/generateSchemas.py">https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/python/generateSchemas.py</a></p>
<p>One should run the script in the X3DJSONLD/src/main/python
folder.</p>
<p>Usage to validate a X3D 4.0 JSON file (python script found online
next to generateSchemas.py):</p>
<p>python3 validate40.py < 4.0_file_name.json</p>
<p>So you can drop the JSON schema entirely with python, if you
wish. AFAICT, right now. This possibly would be advantageous to
an x3d.py JSON "typeless" loader.<br>
</p>
<p>I don't know if we're close to reading a X3D JSON file into a
python X3D model with python. That's probably still a ways out,
I think. Of course, one can read a JSON file already in python.
So these validators provide a bit of type-safety in the short
term, when converting X3D JSON to a X3D model in python. That
is, it's easier to write a validator in the short term, since it's
pretty much a series of commands to the operating system shell,
and a lot of code is available for validating.</p>
<p>Be warned that this package generates an runs unchecked (by me)
python, so you may want to use care.</p>
<p>generateSchemas.py generates the following files:<br>
</p>
<p>> draft07.py<br>
> validate07.py<br>
> ../schema/x3d-{version}-JSONSchema.json<br>
> schemaparser{schemacodeversion}.py<br>
> validate{schemacodeversion}.py</p>
<p>be sure to make backups, fork my repository, if you run the
generateSchemas.py script. The products are already checked in,
so there's no real reason to run it!</p>
<p>I make no statement as to the suitability of fastjsonschema and
jsonlint for any uses that you might have. Do your own research!</p>
<p>Note: Thanks to Roy and Don for creating a great product in
X3DUOM, upon which this is dependent upon.<br>
</p>
<p>Enjoy!<br>
</p>
<p>John<br>
</p>
</body>
</html>