[x3d-public] IMPORT (JSON encoding), should it be an array or object, previously discussed, Mantis issue present in JSON project

John Carlson yottzumm at gmail.com
Fri Apr 2 13:41:16 PDT 2021


IMPORT (JSON encoding), should it be an array or object in X3D JSON 
schema, previously discussed, Mantis issue present in JSON project.

https://www.web3d.org/member-only/mantis/view.php?id=1225

I need to look into previous emails, from months ago, will search my 
archives.

My apologies for resend,  I'm trying to gain visibility for this Mantis 
issue.


0 Ajv 6.0 Validation failed on 
/c/x3d-code/www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/X3dHeaderPrototypeSyntaxExamples.json
^M
  keyword: type^M
  dataPath: X3D > Scene > -children > 18 > IMPORT^M
  value: 
{"@AS":"someInlineRoot","@importedDEF":"someName","@inlineDEF":"someInline"}^M
  message: should be array^M
  params: {"type":"array"}^M
  file: 
/c/x3d-code/www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/X3dHeaderPrototypeSyntaxExamples.json^M
  version: 6.0^M


Autogenerated IMPORT is:

     "IMPORT": {
       "type": "object",
       "properties": {
         "-children": {
           "$ref": "#/definitions/-childrenStatements"
         },
         "@AS": {
           "pattern": "^(\\s|\\S)*$",
           "type": "string"
         },
         "@importedDEF": {
           "pattern": "^(\\s|\\S)*$",
           "type": "string"
         },
         "@inlineDEF": {
           "pattern": "^(\\s|\\S)*$",
           "type": "string"
         }
       },
       "required": [
         "@importedDEF",
         "@inlineDEF"
       ],
       "additionalProperties": false
     },




Roy's IMPORT is:

                 "IMPORT": {
                         "type": "array",
                         "minItems": 1,
                         "items": {
                                 "type": "object",
                                 "properties": {
                                         "@AS": {
                                                 "type": "string"
                                         },
                                         "@importedDEF": {
                                                 "type": "string"
                                         },
                                         "@inlineDEF": {
                                                 "type": "string"
                                         }
                                 },
                                 "required": [
                                         "@importedDEF",
                                         "@inlineDEF"
                                 ],
                                 "additionalProperties": false
                         }
                 },


I have totally forgotten what the discussion about IMPORT was on the 
mailing list and what we decided.  I'm guessing that Roy's schema needs 
to be updated, but there are wiser minds than mine.


X3DUOM is:

       <Statement name="IMPORT">
          <InterfaceDefinition 
specificationUrl="https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-WD3/Part01/concepts.html#IMPORTSemantics"
                               appinfo="Functional summary: IMPORT 
provides ROUTE access to a node that has a corresponding EXPORT 
statement within an Inline scene. These connections allow event values 
to be exchanged via ROUTE statements between a parent model and a child 
Inline model.">
             <componentInfo name="Networking" level="3"/>
             <field name="AS"
                    type="SFString"
                    accessType="inputOutput"
                    baseType="xs:ID"
                    description="map importedDEF name AS a new name in 
current scene."/>
             <field name="importedDEF"
                    type="SFString"
                    accessType="inputOutput"
                    use="required"
                    baseType="xs:NMTOKEN"
                    description="importedDEF is DEF name of the node of 
interest that is contained in the remote inlineDEF scene."/>
             <field name="inlineDEF"
                    type="SFString"
                    accessType="inputOutput"
                    use="required"
                    baseType="xs:IDREF"
                    description="inlineDEF is the DEF name of Inline 
node in the same scene as this IMPORT statement."/>
          </InterfaceDefinition>
       </Statement>


 From the file itself:


           { "IMPORT":
             {
               "@AS":"someInlineRoot",
               "@importedDEF":"someName",
               "@inlineDEF":"someInline"
             }
           },


So this is definitely an object, not an array.   Is an array correct, or 
an object? I will check the v4 draft. I'm not seeing the data structure 
in 9.2.5, will check XML schema


     <xs:element name="IMPORT">
         <xs:annotation>
             <xs:appinfo>
                 <xs:attribute name="componentName" 
type="componentNameChoices" fixed="Networking"/>
                 <xs:attribute name="componentLevel" 
type="xs:positiveInteger" fixed="3"/>
                 Functional summary: IMPORT provides ROUTE access to a 
node that has a corresponding EXPORT statement within an Inline scene.
                 These connections allow event values to be exchanged 
via ROUTE statements between a parent model and a child Inline model.
             </xs:appinfo>
             <xs:documentation 
source="https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-WD3/Part01/concepts.html#IMPORTSemantics"/>
         </xs:annotation>
         <xs:complexType>
             <xs:complexContent>
                 <xs:extension base="SceneGraphStructureStatement">
                     <xs:attribute name="inlineDEF" type="xs:IDREF" 
use="required"/>
                     <xs:attribute name="importedDEF" type="xs:NMTOKEN" 
use="required"/>
                     <xs:attribute name="AS" type="xs:ID"/>
                 </xs:extension>
             </xs:complexContent>
         </xs:complexType>
     </xs:element>


Okay, I don't see anything like array in here, so I will check the JSON 
draft.


The JSON encoding draft has:


<p class="ExampleCode">"IMPORT": [<br>

   {<br>

      "@AS": "myNodeAlias",<br>

      "@importedDEF": "myImportNode",<br>

      "@inlineDEF": "myInline"<br>

   }<br>

]</p>
<p>An example of the encoding of an "IMPORT" object is:</p>


Relevant Mantis Issue is:

https://www.web3d.org/member-only/mantis/view.php?id=1225


Based on the Mantis issue, we need to at least change X3dToJson.xslt to 
produce an array (please double-check my work here), and change schema 
auto-generator to conform to what Roy's schema does.  There may be some 
unknown changes to XML schema and X3DUOM required, but at this time, I 
am unsure.   File date of JSON is Mar 31, 2021.  Likely the file was 
generated by donall.sh.  I would love it if some change to X3DUOM would 
automatically fix the auto-generated schema, but somehow I doubt that 
this is possible.

This line in don.sh, was likely the line that produced the JSON:

(ls "$@" | grep -v intermediate | grep -v "\.new") | xargs -P 
$PROCESSORS java net.coderextreme.RunSaxon ---overwrite ---silent 
--../lib/stylesheets/X3dToJson.xslt ---

$ diff ../lib/stylesheets/X3dToJson.xslt 
/c/x3d-code/www.web3d.org/x3d/stylesheets/X3dToJson.xslt

notes no differences between the stylesheet files.

Found error in auto-generator (used NOde instead of Node), but no 
apparent changes to schemas detected.

On to the next.

On 3/30/21 9:52 PM, John Carlson wrote:
> These files threw a validation error when run against Roy's schema 
> with my modifications.
>
> $ grep "^ file" ../x3dschema/results.txt
>  file: 
> /c/x3d-code/www.web3d.org/x3d/content/examples/Basic/development/MetadataExamples.json
>  file: 
> /c/x3d-code/www.web3d.org/x3d/content/examples/Basic/development/RenderingComponentPrototypes.json
>  file: 
> /c/x3d-code/www.web3d.org/x3d/content/examples/Basic/development/ImportExportSyntax.json
>  file: 
> /c/x3d-code/www.web3d.org/x3d/content/examples/Basic/development/TestMetadataNodes.json
>  file: 
> /c/x3d-code/www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/X3dHeaderPrototypeSyntaxExamples.json
>  file: 
> /c/x3d-code/www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter15Metadata/MetadataNodeExamples.json
>  file: 
> /c/x3d-code/www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/Scanning/X3dMeshDesignPattern.json
>
>
> Anyone care to look to see if it's Roy's schema that's the problem, or 
> the files (look at the last 3 files)? I'm about pooped out for the 
> evening.  I have not run these under Java with Roy's schema yet, but I 
> will if someone wants me to. Someone could set up org.everit on their 
> own system, download draft-07 JSON schema (found in x3dschema) and do 
> the testing with x3d-6.0-JSONSchema.json -- roy's schema (you'll need 
> to modify the *.java files found in x3dschema--no worries, they're 
> extremely simple).
>
>
> To run this test in your own x3dschema folder, do the following patch, 
> then run bash validate.sh (after modifying per your environment).   
> Collect errors in results.txt and other txt files.   Results are 
> stored in results3.txt (autogenerated) and results6.txt (roy's 
> schema).  Everything should be checked in now, under 
> https://github.com/coderextreme/x3dschema
>
>
> diff --git a/validatex3djson.js b/validatex3djson.js
> index bafb455..fcc05ca 100644
> --- a/validatex3djson.js
> +++ b/validatex3djson.js
> @@ -26,7 +26,7 @@ for (var sversion in overallversions) {
>  function testValid(versions, valids, v, file, ajvValidate, hello) {
>         // console.log(valids[0], valids[1], v);
>         // change v == ? and set ? to 0 for my schema reports and set 
> ? to 1 for roy's schema reports
> -       if (valids[0] !== valids[1] && v == 0) {
> +       if (valids[0] !== valids[1] && v == 1) {
>             var errs = ajvValidate[versions[v]].errors;
>             for (var e in errs) {
>                 if (e == 0) {
>
>
> If the 3 last JSON files are the problem, there's a problem with the 
> autogenerated schema.  I just don't have the heart to look right now.
>
>
> So I think we're really close to a good X3D JSON schema, we just need 
> to check these 3 files I think. Then we choose hand-generated (one 
> version) or auto-generated (separate schemas per version, pretty much 
> auto-update as X3DUOM is changed).
>
>
> Thanks,
>
> John
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20210402/870e8243/attachment-0001.html>


More information about the x3d-public mailing list