shexjs / shex.js

shex.js javascript package
MIT License
58 stars 17 forks source link

importing external shex replace the schema.start value #62

Open scenaristeur opened 4 years ago

scenaristeur commented 4 years ago

I want to use shex shapes stored in multiple files, to generate forms from shapes so I have used the 'import' functionnality.

for example , the tension.shex imports ratifier.shex & role.shex . This last imports circle.shex. All shapes are stored https://holacratie.solid.community/public/Schema/

I use shex.js in this page https://scenaristeur.github.io/spoggy-simple/testform.html , which source is here https://github.com/scenaristeur/spoggy-simple/blob/master/testform.html

import <https://holacratie.solid.community/public/Schema/ratifier.shex>
import <https://holacratie.solid.community/public/Schema/role.shex>

PREFIX :       <https://holacratie.solid.community/public/>
PREFIX sx: <http://www.w3.org/ns/shex#>
PREFIX schema: <http://schema.org/>
PREFIX xsd:  <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX hola: <https://holacratie.solid.community/public/>
PREFIX fp: <https://footprint.solid.community/public/>

start = @<Tension>

<Tension> {               # A Tension has:
  :status                  ["preliminary" "final"]; #   status in this value set
  schema:name              xsd:string  ;
  schema:dateCreated       xsd:date?  ;
  schema:creator           :Ratifier 
                            OR @<Ratifier> 
                            OR IRI
                            OR xsd:string ;
  :subject                 :Organization; 
  :whatIs                  LITERAL  ;
  :whatShouldBe            LITERAL  ;

}

<Tension_Footprint> {

( fp:root      [hola: "current POD" <../Tension> ] OR xsd:string ;
  fp:path      ["Tension"] OR xsd:string ;
  fp:filename  ["value of schema:name"] OR xsd:string;
  |  fp:fullpath xsd:string
  ### |
  ###  (   fp:root      ["POD" <../Tension> hola:]  |   fp:root LITERAL+    );
  ###  (   fp:path      ["Tension"]                 |   fp:path LITERAL     );
  ###  (   fp:filename  [schema:name];              |   fp:filename LITERAL );
  ); 
}

I wanted to get the start of the loaded shape with

  shex.Loader.load([shapeUrl], [], [], []).then(function (loaded, err) {
...

  var start = loaded.schema.start;
  console.log(shapes)
  console.log ("start",start)
...

I expected to have a start with the shape "Tension" which correspond to the shape that I want to load, but it appears that it is the start of the last .shex loaded that is stored in the schema.start.

in this example, the start in shcema is the one stored in the import circle.shex and not the one in the file I asked to load.

image

Is it a bug or do I do something Wrong ? thxs David

PS : after an "npm update", 2 security Issues have appeared in your nodes dependencies : deep-extend lodash

ericprud commented 4 years ago

Hmm, does it seem like start2RefS1-IstartS2 should test this?

start2RefS1-IstartS2:

start=@<http://a.example/S1>
<http://a.example/S1> {
   <http://a.example/p1> @<http://a.example/S2>
}

imports start2RefS2:

<http://a.example/S2> {
   <http://a.example/p2> .
}

Test doesn't specify a START so it should pick .

Maybe the npm is behind. Are you using that or a github clone?