[x3d-public] renewed development of X3D JSON support

John Carlson yottzumm at gmail.com
Wed Oct 13 23:29:56 PDT 2021


There's also a good opportunity to add patterns to my generated schema, 
as well as reduce bloat:

~/X3DJSONLD/src/main/schema$ grep pattern x3d-4.0-JSONSchema.json |wc
    3108    6216  239229
~/X3DJSONLD/src/main/schema$ grep pattern x3d-4.0-JSONSchema.json |sort 
-u|wc
      27      54    3529

X3DUOM may point the way:

X3DJSONLD/src/specifications$ grep regex X3dUnifiedObjectModel-4.0.xml |wc
      41      41    5874

X3DJSONLD/src/specifications$ grep regex X3dUnifiedObjectModel-4.0.xml 
|sort -u|wc
      24      24    3401

Can we reduce the number of regex's in X3DUOM, 
X3dXml4.0SchemaConvertedToJson2020-12Schema.json and 
x3d-4.0-JSONSchema.json? Do we want to? Should we add xs: to X3D JSON 
schema?

Normally ny X3D JSON schema does not have patterns, I just added them 
temporarily to get a feel for it.

My first suggestion is to get patterns working with 
x3d-4.0-JSONSchema.json and 
X3dXml4.0SchemaConvertedToJson2020-12Schema.json in at least one 
programming language.

This program may help as it deals with both schemas in python:

rom jsonschema import validate
import json
import sys


# validate stdin against the X3D4 JSON schemas

try:
     instance = json.loads(sys.stdin.read())
     sys.stdout.write("jsonValid ")
except:
     sys.stdout.write("jsonInvalid ")

try:
     with open('../schema/x3d-4.0-JSONSchema.json', 'r') as schemafile:
         schema = json.load(schemafile)
         validate(instance=instance, schema=schema)
         sys.stdout.write("jwcValid ")
except:
         sys.stdout.write("jwcInvalid ")
sys.stdout.flush()

try:
     with 
open('../schema/X3dXml4.0SchemaConvertedToJson2020-12Schema.json', 'r') 
as schemafile:
         schema = json.load(schemafile)
         validate(instance=instance, schema=schema)
         sys.stdout.write("dbValid ")
except:
         sys.stdout.write("dbInvalid ")
sys.stdout.flush()

Thanks,

John

On 10/14/21 1:06 AM, John Carlson wrote:
>
> X3dXml4.0SchemaConvertedToJson2020-12Schema.json has many XML'isms:
>
>
> X3DJSONLD/src/main/schema$ grep xs: 
> X3dXml4.0SchemaConvertedToJson2020-12Schema.json |sort -u
>                                         "$ref": "#/$defs/xs:ID"
>                                         "$ref": "#/$defs/xs:IDREF"
>                                         "$ref": "#/$defs/xs:NMTOKEN"
>                                         "$ref": "#/$defs/xs:NMTOKENS"
>                 "xs:ID": {
>                 "xs:IDREF": {
>                 "xs:NMTOKEN": {
>                 "xs:NMTOKENS": {
>
>
> What should I do?
>
> My schema does not contain any xs: tags.
>
> Here are how these types are defined in 
> X3dXml4.0SchemaConvertedToJson2020-12Schema.json
>
>                 "xs:ID": {^M
>                         "pattern": 
> "^([A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿<200c>-<200d>⁰-↏Ⰰ-⿯、-퟿>豈-﷏ﷰ-�𐀀-󯿿][\\d\\--\\.A-Z_a-z·À-ÖØ-öø-ͽͿ-ٟ٪-ۯۺ-޿ߊ-॥॰-৥ৰ-੥ੰ-૥૰-୥୰-௥௰-౥౰-೥೰-൥൰-෥෰-๏๚-໏໚-༟༪-ဿ၊-ႏႚ-៟៪-᠏᠚-᥅ᥐ-᧏᧚-᩿᪊-᪏᪚-᭏᭚-ᮯᮺ-᰿᱊-ᱏᱚ-῿<200c>-<200d>‿-⁀⁰-↏Ⰰ-⿯、-ꘟꘪ-꣏꣚-ꤊ-ꧏ꧚-ꧯꧺ-꩏꩚-꯯꯺-퟿﷏ﷰ-/:-�𐀀-𐒟𐒪-𑁥𑁰-𑃯𑃺-𑄵𑅀-𑇏𑇚-𑋯𑋺-𑑏𑑚-𑓏𑓚-𑙏𑙚-𑚿𑛊-𑜯𑜺-𑣟𑣪-𑱏𑱚-𖩟𖩪-𖭏𖭚-𝟍𝠀-𞥏𞥚-󯿿]*)$",^M
>                         "type": "string"^M
>                 },^M
>                 "xs:IDREF": {^M
>                         "pattern": 
> "^([A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿<200c>-<200d>⁰-↏Ⰰ-⿯、-퟿>豈-﷏ﷰ-�𐀀-󯿿][\\d\\--\\.A-Z_a-z·À-ÖØ-öø-ͽͿ-ٟ٪-ۯۺ-޿ߊ-॥॰-৥ৰ-੥ੰ-૥૰-୥୰-௥௰-౥౰-೥೰-൥൰-෥෰-๏๚-໏໚-༟༪-ဿ၊-ႏႚ-៟៪-᠏᠚-᥅ᥐ-᧏᧚-᩿᪊-᪏᪚-᭏᭚-ᮯᮺ-᰿᱊-ᱏᱚ-῿<200c>-<200d>‿-⁀⁰-↏Ⰰ-⿯、-ꘟꘪ-꣏꣚-ꤊ-ꧏ꧚-ꧯꧺ-꩏꩚-꯯꯺-퟿﷏ﷰ-/:-�𐀀-𐒟𐒪-𑁥𑁰-𑃯𑃺-𑄵𑅀-𑇏𑇚-𑋯𑋺-𑑏𑑚-𑓏𑓚-𑙏𑙚-𑚿𑛊-𑜯𑜺-𑣟𑣪-𑱏𑱚-𖩟𖩪-𖭏𖭚-𝟍𝠀-𞥏𞥚-󯿿]*)$",^M
>                         "type": "string"^M
>                 },^M
>                 "xs:NMTOKEN": {^M
>                         "pattern": 
> "^([\\d\\--\\.\\:A-Z_a-z·À-ÖØ-öø-ͽͿ-ٟ٪-ۯۺ-޿ߊ-॥॰-৥ৰ-੥ੰ-૥૰-୥୰-௥௰-౥౰-೥೰-൥൰-෥෰-๏๚-໏໚-༟༪-ဿ၊-ႏႚ-៟៪-᠏᠚-᥅ᥐ-᧏᧚-᩿᪊-᪏᪚-᭏᭚-ᮯᮺ-᰿᱊-ᱏᱚ-῿<200c>-<200d>‿-⁀⁰Ⰰ-⿯、-ꘟꘪ-꣏꣚-ꤊ-ꧏ꧚-ꧯꧺ-꩏꩚-꯯꯺-퟿豈-﷏ﷰ-/:-�𐀀-𐒟𐒪-𑁥𑁰-𑃯𑃺-𑄵𑅀-𑇏𑇚-𑋯𑋺-𑑏𑑚-𑓏𑓚-𑙏𑙚-𑚿𑛊-𑜯𑜺-𑣟𑣪-𑱏𑱚-𖩟𖩪-𖭏𖭚-𝟍𝠀-𞥏𞥚-󯿿]+)$",^M
>                         "type": "string"^M
>                 },^M
>                 "xs:NMTOKENS": {^M
>                         "items": {^M
>                                 "pattern": 
> "^([\\d\\--\\.\\:A-Z_a-z·À-ÖØ-öø-ͽͿ-ٟ٪-ۯۺ-޿ߊ-॥॰-৥ৰ-੥ੰ-૥૰-୥୰-௥௰-౥౰-೥೰-൥൰-෥෰-๏๚-໏໚-༟༪-ဿ၊-ႏႚ-៟៪-᠏᠚-᥅ᥐ-᧏᧚-᩿᪊-᪏᪚-᭏᭚-ᮯᮺ-᰿᱊-ᱏᱚ-῿<200c>-<2d>‿-⁀⁰-↏Ⰰ-⿯、-ꘟꘪ-꣏꣚-ꤊ-ꧏ꧚-ꧯꧺ-꩏꩚-꯯꯺-퟿豈-﷏ﷰ-/:-�𐀀-𐒟𐒪-𑁥𑁰-𑃯𑃺-𑄵𑅀-𑇏𑇚-𑋯𑋺-𑑏𑑚-𑓏𑓚-𑙏𑙚-𑚿𑛊-𑜯𑜺-𑣟𑣪-𑱏𑱚-𖩟𖩪-𖭏𖭚-𝟍𝠀-𞥏𞥚-󯿿]+)$",^M
>                                 "type": "string"^M
>                         },^M
>                         "type": "array"^M
>                 }^M
>
> Here's a summary of X3DUOM:
>
> $ grep xs: X3dUnifiedObjectModel-4.0.xml|sort -u
>                    baseType="xs:ID"
>                    baseType="xs:IDREF"
>                    baseType="xs:NMTOKEN"
>                    baseType="xs:NMTOKEN"/>
>                    baseType="xs:NMTOKEN">
>                   baseType="xs:NMTOKEN"
>                    baseType="xs:NMTOKENS"
>             <containerField default="acousticProperties" 
> type="xs:NMTOKEN"/>
>             <containerField default="appearance" type="xs:NMTOKEN"/>
>             <containerField default="attrib" type="xs:NMTOKEN"/>
>             <containerField default="bodies" type="xs:NMTOKEN">
>             <containerField default="children" type="xs:NMTOKEN"/>
>             <containerField default="collider" type="xs:NMTOKEN"/>
>             <containerField default="contacts" type="xs:NMTOKEN"/>
>             <containerField default="coord" type="xs:NMTOKEN"/>
>             <containerField default="displacers" type="xs:NMTOKEN"/>
>             <containerField default="emitter" type="xs:NMTOKEN"/>
>             <containerField default="fillProperties" type="xs:NMTOKEN"/>
>             <containerField default="fogCoord" type="xs:NMTOKEN"/>
>             <containerField default="fontStyle" type="xs:NMTOKEN"/>
>             <containerField default="geometry" type="xs:NMTOKEN"/>
>             <containerField default="geoOrigin" type="xs:NMTOKEN"/>
>             <containerField default="joints" type="xs:NMTOKEN"/>
>             <containerField default="layers" type="xs:NMTOKEN"/>
>             <containerField default="layout" type="xs:NMTOKEN"/>
>             <containerField default="lineProperties" type="xs:NMTOKEN"/>
>             <containerField default="material" type="xs:NMTOKEN"/>
>             <containerField default="motions" type="xs:NMTOKEN"/>
>             <containerField default="periodicWave" type="xs:NMTOKEN"/>
>             <containerField default="physics" type="xs:NMTOKEN"/>
>             <containerField default="pointProperties" type="xs:NMTOKEN"/>
>             <containerField default="programs" type="xs:NMTOKEN"/>
>             <containerField default="renderStyle" type="xs:NMTOKEN"/>
>             <containerField default="shaders" type="xs:NMTOKEN"/>
>             <containerField default="texCoord" type="xs:NMTOKEN"/>
>             <containerField default="textureProperties" 
> type="xs:NMTOKEN"/>
>             <containerField default="textureTransform" type="xs:NMTOKEN"/>
>             <containerField default="texture" type="xs:NMTOKEN"/>
>             <containerField default="trimmingContour" type="xs:NMTOKEN"/>
>             <containerField default="viewport" type="xs:NMTOKEN"/>
>       <!-- For schema xs:simpleType with contained xs:enumeration 
> definitions, follow naming convention of name ending in 'Type', 
> 'Choices' (for strict enumeration set) or 'Values' (for suggested 
> tokens). -->
>             <Inheritance baseType="xs:boolean"/>
>             <Inheritance baseType="xs:double"/>
>             <Inheritance baseType="xs:float"/>
>             <Inheritance baseType="xs:integer"/>
>             <Inheritance baseType="xs:string"/>
>
> containerField is not mentioned at all in my schema. xs: is not 
> mentioned in my schema generator.
>
> I cannot extract patterns from X3DUOM if they don't exist.  I can add 
> patterns to my schema generator, if someone puts them into JSON 
> encoding.  I can add these patterns as text.
>
> There's even a good opportunity to reduce the number of patterns in 
> X3dXml4.0SchemaConvertedToJson2020-12Schema.json:
>
> (venv) 
> coderextreme at coderextreme-Kubuntu20:~/X3DJSONLD/src/main/schema$ 
> jsonlint X3dXml4.0SchemaConvertedToJson2020-12Schema.json|grep pattern|wc
>      96     192   39020
> (venv) 
> coderextreme at coderextreme-Kubuntu20:~/X3DJSONLD/src/main/schema$ 
> jsonlint X3dXml4.0SchemaConvertedToJson2020-12Schema.json|grep 
> pattern|sort -u|wc
>      25      50    6183
>
> John
>
> On 10/13/21 7:36 PM, Brutzman, Donald (Don) (CIV) wrote:
>>
>> The Altova XML Spy generated schema is not a solution, it is an 
>> example showing design patterns that may be useful.
>>
>> converted X3D JSON schema, would be my guess.
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20211014/b2a6fbf0/attachment-0001.html>


More information about the x3d-public mailing list