Git Product home page Git Product logo

shex.js's People

Contributors

andrawaag avatar dbooth-boston avatar dependabot[bot] avatar elf-pavlik avatar ericprud avatar glenna-m avatar gnomus042 avatar joeltg avatar l0vecraft avatar labra avatar lucaswerkmeister avatar maxlath avatar micgro42 avatar mrolympia avatar tombaker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shex.js's Issues

pear-shaped timeout problem

Demo form URL entry is missing

When loading the demo in Chrome or Firefox, the form field to input a URL to validate against is missing. We can inspect the page and see the source code there, so it looks like a styling issue?

<div id="loadForm" style="cursor: default; text-align: left; ">
--
  | <h1>Load <span></span></h1>
  | <p class="menuitem"><label for="loadInput" style="float: left;">from </label><input id="loadInput" style="width: 80%;"/></p>
  | <p class="validateTips">Enter a URL.</p>
  | </div>

This is what I'm seeing on Chrome:

image

In Firefox I have access to the controls too which also don't seem to work on Chrome, but these don't seem to affect these fields?

Error parsing schema

I´m not able to parse the following schema:

 PREFIX : <http://www.example.com>
 PREFIX schema:    <http://schema.org/>
 PREFIX xsd:    <http://www.w3.org/2001/XMLSchema#>

 :User{
      schema:knows  xsd:string @:User 
  }

It throws the following error:

Error: undefined(6): Parse error on line 6:
...      schema:knows  xsd:string @:User   }
---------------------------------^
Expecting 'EOF', 'IT_BASE', 'IRIREF', 'IT_PREFIX', 'PNAME_NS', 'IT_IMPORT', 'IT_start', 'IT_OR', 'IT_AND', ')', '.', 'IT_IRI', 'IT_BNODE', 'IT_NONLITERAL', 'INTEGER', 'REGEXP', 'IT_LENGTH', 'IT_MINLENGTH', 'IT_MAXLENGTH', 'DECIMAL', 'DOUBLE', 'STRING', 'IT_MININCLUSIVE', 'IT_MINEXCLUSIVE', 'IT_MAXINCLUSIVE', 'IT_MAXEXCLUSIVE', 'IT_TOTALDIGITS', 'IT_FRACTIONDIGITS', '}', '|', ',', ';', '*', '+', '?', 'REPEAT_RANGE', ']', '~', '-', 'LANGTAG', '//', '%', 'LANG_STRING', 'IT_true', 'IT_false', 'PNAME_LN', 'BLANK_NODE_LABEL', got 'ATPNAME_LN'
...      schema:knows  xsd:string @:User   }
---------------------------------^
    at Object.<anonymous> (D:\Repositories\shexjs\main.js:3:38)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47

I think an "and" keyword is expected between the node constraint and the shapeRef, but the shex grammar allows it to be omitted, doesn't it?

annotation on shape

Either the implementation and/or the spec in incomplete/buggy on annotations for shapes.

In the spec there is

Annotations provide a format-independent way to provide additional information about elements in a schema. They appear in lists in Shape, OneOf, EachOf and TripleConstraint's annotations.

and there is

[18] shapeDefinition ::= (extraPropertySet | "CLOSED")* "{" tripleExpression? "}" annotation* semanticActions

However the Shape in the ShexR and json has no property for annotation, but the EachOf can have an annotation. So the shape annotation can be moved the EachOf object.

However when running the following code

PREFIX : <http://hl7.org/fhir/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start = @<ObservationShape>

<ObservationShape> {          
  :status xsd:integer;
}
// :test "val"

Gives

error parsing input schema:
Error: unknown property: "annotations" in Shape: {"type":"Shape","expression":{"type":"TripleConstraint","predicate":"http://hl7.org/fhir/status","valueExpr":{"type":"NodeConstraint","datatype":"http://www.w3.org/2001/XMLSchema#integer"}},"annotations":[{"type":"Annotation","predicate":"http://hl7.org/fhir/test","object":{"value":"val"}}]}

Additionally I would prefer if the syntax would look like as

<ObservationShape> {          
  // :test "val"
  :status xsd:integer;
}

Validation process appears to exhaust all available memory

I’ve reduced my shape expression to this fairly short snippet:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX schema: <http://schema.org/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX ex: <http://example.com/>

ex:A {
  schema:description rdf:langString+;
  wdt:P106 @ex:B
}

ex:B {
  schema:description rdf:langString+;
  schema:name rdf:langString+;
  rdfs:label rdf:langString+
}

Let’s say you’ve saved this as /tmp/ex.shex. If you then try to validate this against Q19296, a fairly small Wikidata example item, using the command

bin/validate \
  --data 'http://www.wikidata.org/entity/Q19296' \
  --shex '/tmp/ex.shex' \
  --node 'http://www.wikidata.org/entity/Q19296' \
  --shape 'http://example.com/A'

then Node.js will fairly quickly (within less than ten seconds on my system) crash with a fatal out-of-memory error. (You probably don’t want to try this in a browser – for me, that hung up the whole system for a while.)

<--- Last few GCs --->

[28338:0x5573831c1570]     5324 ms: Scavenge 1383.4 (1410.8) -> 1383.3 (1412.3) MB, 3.9 / 0.0 ms  (average mu = 0.201, current mu = 0.137) allocation failure                                                     
[28338:0x5573831c1570]     5329 ms: Scavenge 1384.6 (1412.3) -> 1384.5 (1413.3) MB, 4.1 / 0.0 ms  (average mu = 0.201, current mu = 0.137) allocation failure                                                     
[28338:0x5573831c1570]     5335 ms: Scavenge 1386.8 (1414.5) -> 1386.8 (1416.0) MB, 3.7 / 0.0 ms  (average mu = 0.201, current mu = 0.137) allocation failure                                                     


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x2b39af19e589 <JSObject>
    0: builtin exit frame: concat(this=0x20b22af022d1 <JSArray[149730]>,0x20b22af02279 <JSArray[155]>,0x20b22af022d1 <JSArray[149730]>)                                                                           

    1: /* anonymous */ [0x1d8016002239] [/home/lucas/git/shex.js/lib/regex/threaded-val-nerr.js:~192] [pc=0x12bbaa51b858](this=0x78964086519 <JSGlobal Object>,nextThreads=0x20b22af022d1 <JSArray[149730]>,exprThread=0x19da8e58ced9 <Object map = 0x5c64157d91>)
  ...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: node::Abort() [node]
 2: 0x557381b65c1f [node]
 3: v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0x55738208f3b3 [node]
 6: 0x55738208f505 [node]
 7: v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]                                                                                                      
 8: v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]                                                                          
 9: v8::internal::Heap::AllocateRawWithRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [node]                                                                                        
10: v8::internal::Factory::AllocateRawArray(int, v8::internal::PretenureFlag) [node]
11: v8::internal::Factory::NewFixedArrayWithFiller(v8::internal::Heap::RootListIndex, int, v8::internal::Object*, v8::internal::PretenureFlag) [node]                                                             
12: v8::internal::Factory::NewJSArrayStorage(v8::internal::Handle<v8::internal::JSArray>, int, int, v8::internal::ArrayStorageAllocationMode) [node]                                                              
13: v8::internal::Factory::NewJSArray(v8::internal::ElementsKind, int, int, v8::internal::ArrayStorageAllocationMode, v8::internal::PretenureFlag) [node]                                                         
14: v8::internal::ElementsAccessor::Concat(v8::internal::Isolate*, v8::internal::Arguments*, unsigned int, unsigned int) [node]                                                                                   
15: 0x557381d88649 [node]
16: 0x557381d8f78f [node]
17: 0x12bbaa109efd
Aborted (core dumped)

Commenting out any of the lines in the ShEx code makes the validation pass, so it feels like this is not a problem with any particular part of the shape, but rather like shex.js is just getting overwhelmed by the sheer amount of labels and descriptions?

Any ideas what could be done here? :/

recursion loophole

Following shema and data, results in a pass while should give a failure.

This is triggered because the ( :test @<A>* | :test @<E>* ); causes a recursive check on <a> and then <c>. When <c> is checked it gets the success status because <a> is in the recursion cache.
So when :test2 @<C> ; is executed <c> is already in the passed list and so it will pass.

Schema: [[
PREFIX : <http://hl7.org/fhir/> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start = @<D>

<D> {
  :predd xsd:string ;
  ( :test @<A>* | :test @<E>* );
  :test2 @<C> ;
}
<E> { :prede xsd:string ; }
<A> { :subject @<C> ; :preda xsd:string }
<C> { :subject @<A> ; :predc xsd:string }
]]

Data: [[
PREFIX : <http://hl7.org/fhir/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

<d> :predd "final" ; :test <a> ; :test2 <c> .
<a> :subject   <c> ; :prede    "final" .
<c> :subject   <a> ; :predc    "final" .
]]

Publish an npm package supporting extends and abstract?

The shumlex project, which converts ShEx to UML diagrams, is based on the ShEx.js parser.

It would be great to add extends and abstract support because they could have nice UML visualization but I think the ShEx.js version published in npm is based on the master branch and doesn't have support for extends yet.

Would it be possible to have an npm package published with support for extends...or are you waiting until they are accepted by the ShEx community group as a new release?

By now, we have opened this issue in Shumlex.

Nested EachOf results have extra expressions

Suppose I have a schema made of two EachOf expressions:

PREFIX schema: <http://schema.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start={
  rdf:type [ schema:Person ],
  (
    schema:givenName xsd:string ,
    schema:familyName xsd:string
  ) *
}

... this parses into

{
  "type": "Schema",
  "start": {
    "type": "Shape",
    "expression": {
      "type": "EachOf",
      "expressions": [
        {
          "type": "TripleConstraint",
          "predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
          ...
        },
        {
          "type": "EachOf",
          "expressions": [
            {
              "type": "TripleConstraint",
              "predicate": "http://schema.org/givenName",
              ...
            },
            {
              "type": "TripleConstraint",
              "predicate": "http://schema.org/familyName",
              ...
            }
          ],
          "min": 0,
          "max": -1
        }
      ]
    }
  }
}

But if I validate against

<http://example.com/john> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .
<http://example.com/john> <http://schema.org/givenName> "John" .
<http://example.com/john> <http://schema.org/familyName> "Doe" .

shex.js produces

{
  "type": "ShapeTest",
  "node": "http://example.com/john",
  "shape": {
    "term": "START"
  },
  "solution": {
    "type": "EachOfSolutions",
    "solutions": [
      {
        "type": "EachOfSolution",
        "expressions": [
          {
            "type": "TripleConstraintSolutions",
            "predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
            "solutions": [ { ... } ],
            "valueExpr": { .. }
          },
          {
            "type": "EachOfSolutions",
            "solutions": [
              {
                "type": "EachOfSolution",
                "expressions": [
                  {
                    "type": "TripleConstraintSolutions",
                    "predicate": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
                    "solutions": [ { ... } ],
                    "valueExpr": { ... }
                  },
                  {
                    "type": "TripleConstraintSolutions",
                    "predicate": "http://schema.org/givenName",
                    "solutions": [ { ... } ],
                    "valueExpr": { ... }
                  },
                  {
                    "type": "TripleConstraintSolutions",
                    "predicate": "http://schema.org/familyName",
                    "solutions": [ { ... } ],
                    "valueExpr": { ... }
                  }
                ]
              }
            ],
            "min": 0,
            "max": -1
          }
        ]
      }
    ]
  }
}

The second EachOfSolution (the nested one) has an array of three expressions, where one is a TripleConstraintSolutions with predicate http://www.w3.org/1999/02/22-rdf-syntax-ns#type - which is copied/duplicated from the first EachOf expression (the outer / not nested one).

In fact the referenced objects are the same: result.solution.solutions[0].expressions[0] === result.solution.solutions[0].expressions[1].solutions[0].expressions[0].

If another solution to the nested EachOf is added - like validating against

<http://example.com/john> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .
<http://example.com/john> <http://schema.org/givenName> "John" .
<http://example.com/john> <http://schema.org/familyName> "Doe" .
<http://example.com/john> <http://schema.org/givenName> "JOHN" .
<http://example.com/john> <http://schema.org/familyName> "DOE" .

then only the first nested EachOfSolution has three expressions, and the second nested EachOfSolution has just the two expected expressions.

Is this correct? I would have expected the expression tree in results to match the expression tree of the schema.

Complete demo code is here. Thanks again for all the work on ShEx! This isn't a critical bug for us or anything, just something I though I'd point out.

Comments not parsing right for external references

PREFIX fhir: <http://hl7.org/fhir/>
PREFIX fhirvs: <http://hl7.org/fhir/ValueSet/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
BASE <http://hl7.org/fhir/shape/>

fhirvs:event-timing EXTERNAL

# Codes identifying the types of relationships between two plans.

Fails with error:

(6): Parse error on line 6:
...fhirvs:event-timing EXTERNAL# Codes id

"Accept: application/json" to window.shexLoader.load

Hi,
I'd like to build forms from .shex shape in https://scenaristeur.github.io/solid-vue-panes/editor

I use shexLoader.load like that https://github.com/scenaristeur/solid-vue-panes/blob/a5886ed69ca6f72b76981be8bb1dc5f34d6ea213/src/mixins/crud/ShexMixin.js#L16

I would like to allow Shaperepo shapes too like https://shaperepo.com/shapes?id=https%3A%2F%2Fshaperepo.com%2Fschemas%2FlongChat

As @jaxoncreed indicates
image

so, i should add "Accept: application/json" to "window.shexLoader.load([shape_url], [], [], []).then(loaded => {"

could you indicate me what is the way to add "Accept" to shexLoader.lod() function
THxs

Shex-simple controls menu overlapping about page

What broken?

shexjs in browser

Version

No response

What happened (e.g., it crashed)?

When in the simple version (https://shex.io/webapps/shex.js/doc/shex-simple.html) of the webapp you click the controls, and then the about button, the controls remain and go over the new about window.

What should have happened instead (e.g., it shouldn't crash)?

The about window should become the top window. I suggest adding a z-value to the node that makes the about window of over 127, I think that is https://github.com/shexjs/shex.js/blob/main/packages/shex-webapp/doc/shex-simple.html line 262.

How can we reproduce this error?

To reproduce the error, open the page, open the controls, then press the about button

npm install fails

When I run npm install shex.js (as in README), I get this error message:

$ npm install shex.js
npm ERR! code E404
npm ERR! 404 Not Found: shex.js@latest

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2018-09-22T12_30_45_453Z-debug.log

Can't use shex in a browser

I can't use shex.js in a browser. When I import it with jspm:

<script type="module" src="https://dev.jspm.io/shex"></script>

I get this error:

N3.dew.js:17 Uncaught ReferenceError: require is not defined
    at dew (N3.dew.js:17)
    at ShExUtil.dew.js:15
    at dew (ShExUtil.dew.js:1993)
    at ShExJison.dew.js:3052
    at dew (ShExJison.dew.js:4123)
    at ShExParser.dew.js:16
    at dew (ShExParser.dew.js:81)
    at dew (shex.dew.js:17)
    at shex:2

Is there another way of doing this?

Duplicate output

Description of problem

The validator outputs the same validation errors multiple times

E.g.

[
     {
       "type": "MissingProperty",
       "property": "[http://www.wikidata.org/prop/direct/P137](https://www.wikidata.org/prop/direct/P137)"
     },
     {
       "type": "MissingProperty",
       "property": "[http://www.wikidata.org/prop/direct/P625](https://www.wikidata.org/prop/direct/P625)",
       "valueExpr": {
         "type": "NodeConstraint",
         "datatype": "http://www.w3.org/2001/XMLSchema#coordinate"
       }
     }
   ],
   [
     {
       "type": "MissingProperty",
       "property": "[http://www.wikidata.org/prop/direct/P137](https://www.wikidata.org/prop/direct/P137)"
     },
     {
       "type": "MissingProperty",
       "property": "[http://www.wikidata.org/prop/direct/P625](https://www.wikidata.org/prop/direct/P625)",
       "valueExpr": {
         "type": "NodeConstraint",
         "datatype": "http://www.w3.org/2001/XMLSchema#coordinate"
       }
     }
   ],

URL to affected spec or repo:
See details under second try here: https://www.wikidata.org/wiki/User:So9q/shexjs#Usage

What happened (e.g., it crashed)?:
Unexpected duplicate output

Expected behavior (e.g., it shouldn't crash):
No duplicate output

Optional, steps to reproduce:

  1. ...

ShEx as RDF

Hi, is it possible to convert ShEx as RDF with JavaScript?

Apparently it can be converted to JSON, but this is just an arbitrary JSON schema which cannot be understand by machines.

Would it be possible to provide a conversion of a ShEx file as RDF? Ideally JSON-LD, but this could be any RDF format.

Validating all nodes of type with --node-type fails

I could not successfully use this option to validate all nodes of type school:Student with:

shex/bin/validate -x enrollee.shex -d alice-bob.ttl -t http://school.example/#Student -s http://school.example/#Enrollee

This ends up in an error:

aborting: TypeError: loaded.data.getTriplesByIRI is not a function
    at knownType (shex/bin/validate:132:25)
    at Function.parsePassedNode (shex/lib/ShExUtil.js:1555:9)
    at _makeShapeMap (shex/bin/validate:148:35)
    at findNodesAndValidate (shex/bin/validate:212:10)
    at shex/bin/validate:287:17
    at process._tickCallback (internal/process/next_tick.js:68:7)

Whereas validating the single nodes work:

shex/bin/validate -x enrollee.shex -d alice-bob.ttl -n http://example.com/users/Bob -s http://school.example/#Enrollee

enrollee.shex:

PREFIX ex: <http://ex.example/#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX school: <http://school.example/#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

school:enrolleeAge xsd:integer MinInclusive 13 MaxInclusive 20 

school:Enrollee {
  foaf:age @school:enrolleeAge ;
  ex:hasGuardian IRI {1,2}
}

alice-bob.ttl:

PREFIX ex: <http://ex.example/#>
PREFIX inst: <http://example.com/users/>
PREFIX school: <http://school.example/#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

inst:Alice a school:Student ;
  foaf:age 23 ;                     
  ex:hasGuardian inst:Person2, inst:Person3 .

inst:Bob a school:Student ;
  foaf:age 15 ;                       
  ex:hasGuardian inst:Person4 .

Named shape with AND, OR statements fails

Given data:

PREFIX : <http://hl7.org/fhir/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

<Obs1>
  :base    "final" ;
  :a   "a" .

Then this schema works as expected

PREFIX : <http://hl7.org/fhir/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start = @<Test>

<Test> {             
  :base xsd:string; 
} 
 AND ({
  :a xsd:string;
} OR
 {
  :b xsd:string;
})

However if I used named shapes it does not work anymore

PREFIX : <http://hl7.org/fhir/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start = @<Test>

<Test> {            
  :base xsd:string; 
} 
 AND (<SubTestA> OR <SubTestB>)

<SubTestA> {
  :a xsd:string;
}


<SubTestB> {
  :b xsd:string;
}

infinite loop

The shema

PREFIX : <http://hl7.org/fhir/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start = @<ObservationShape>

<ObservationShape> {               # An Observation has:
  (:status xsd:integer* | :status xsd:string* )*
}

with data

PREFIX : <http://hl7.org/fhir/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

<Obs1>
  :status    "final" .

causes a infinite loop

Validation failing for shape with only an optional group

I believe that this is a valid shape:

PREFIX schema: <http://schema.org/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

start = @_:organization

_:organization bnode {
  a [ schema:Organization ] ;
  ( schema:alumni @_:person ) * ;
}

_:person bnode {
  (
    schema:givenName xsd:string ;
    schema:familyName xsd:string ;
  ) ? ;
}

Testing this with

const fs = require("fs")
const N3 = require("n3")

const ShExParser = require("@shex/parser")
const ShExCore = require("@shex/core")

const s = fs.readFileSync("test2.shex", "utf8")

const schema = ShExParser.construct().parse(s)
const validator = ShExCore.Validator.construct(schema)

const store = new N3.Store()
new N3.StreamParser({ format: "application/n-quads", blankNodePrefix: "_:" })
  .on("data", quad => store.addQuad(quad))
  .on("end", () => {
    const db = ShExCore.Util.makeN3DB(store)
    const result = validator.validate(db, "_:b0", schema.start)
    console.log(JSON.stringify(result, null, "  "))
  }).end(`
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Organization> .
_:b0 <http://schema.org/alumni> _:b1 .
_:b1 <http://schema.org/givenName> "Joel" .
_:b1 <http://schema.org/familyName> "Gustafson" .
`)

does indeed produce a valid ShapeAndResults object, but testing without the last two triples - just

_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Organization> .
_:b0 <http://schema.org/alumni> _:b1 .

... throws an error:

% node test.js
/Users/joel/Projects/pkgm/shex.js/packages/shex-core/lib/regex/threaded-val-nerr.js:346
      if (Object.keys(fromValidatePoint).length > 0) // guard against {}
                 ^

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at finish (/Users/joel/Projects/pkgm/shex.js/packages/shex-core/lib/regex/threaded-val-nerr.js:346:18)
    at Object.match (/Users/joel/Projects/pkgm/shex.js/packages/shex-core/lib/regex/threaded-val-nerr.js:264:9)
    at ShExValidator_constructor._validateShape (/Users/joel/Projects/pkgm/shex.js/packages/shex-core/lib/ShExValidator.js:609:33)
    at ShExValidator_constructor._validateShapeExpr (/Users/joel/Projects/pkgm/shex.js/packages/shex-core/lib/ShExValidator.js:429:19)
    at ShExValidator_constructor._validateShapeExpr (/Users/joel/Projects/pkgm/shex.js/packages/shex-core/lib/ShExValidator.js:454:24)
    at ShExValidator_constructor.validate (/Users/joel/Projects/pkgm/shex.js/packages/shex-core/lib/ShExValidator.js:393:20)
    at _errorsByShapeLabel (/Users/joel/Projects/pkgm/shex.js/packages/shex-core/lib/ShExValidator.js:502:34)
    at ShExValidator_constructor._errorsMatchingShapeExpr (/Users/joel/Projects/pkgm/shex.js/packages/shex-core/lib/ShExValidator.js:700:24)
    at /Users/joel/Projects/pkgm/shex.js/packages/shex-core/lib/ShExValidator.js:688:26

I'm using the latest master (aeef29e) with N3 v1.3.5.

`@types/shexj` doesn't have a corresponding package `shexj` on npm

Description of problem

It seems that @types/shexj doesn't have a corresponding package shexj published on npmjs.com.

The types can still be imported in projects, e.g. in this and other libraries:

import * as ShExJ from 'shexj';

// use e.g. type ShExJ.Schema somewhere here

But this situation seems non-standard, and personally i find it confusing.

Is it intentional, or is the @types/shexj package a leftover from some historic package?

I'm opening the issue here, since this seems the most relevant repository i could find, and it seems that authors/maintainers overlap @ericprud

This doesn't cause me any issues. I bumped into this when resolving an unrelated issue with eslint rule import/no-unresolved. Just curious i guess... 🙂

Enable discussion?

Hi, I have questions related to output of this validator that I would like to post in a discussion instead of opening a bug every time I have a question. Would you be willing to enable the discussion feature?

Service crashes when shape is redefined

PREFIX fhir: <http://hl7.org/fhir/>
PREFIX fhirvs: <http://hl7.org/fhir/ValueSet/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
BASE <http://hl7.org/fhir/shape/>

start=@<CarePlan> AND {fhir:nodeRole [fhir:treeRoot]}


# Healthcare plan for patient or group
<CarePlan> { a fhir:CarePlan }

<CarePlan> { a fhir:CarePlan }

causes the ShEx validator to crash.

aborting: Error: file:///Users/mrf7578/Development/git/shexSpec/shex.js/foo.shex(14): Parse error: http://hl7.org/fhir/shape/CarePlan alread defined
...{ a fhir:CarePlan }
----------------------^
    at parseShExC (/Users/mrf7578/Development/git/shexSpec/shex.js/lib/ShExLoader.js:102:54)

shex-validator Error.captureStackTrace is not a function (alpha 24 in browser)

Description of problem

When shex-validator encounters an error, it will attempt to "Capture Stack Trace." (https://github.com/shexjs/shex.js/blob/shex-next/packages/shex-validator/shex-validator.js#L1504) This function isn't available in web browsers and causes it to fail inelegantly.

URL to affected spec or repo: https://github.com/shexjs/shex.js/blob/shex-next/packages/shex-validator/shex-validator.js#L1504

What happened (e.g., it crashed)?: The error Error.captureStackTrace is not a function is thrown.

Expected behavior (e.g., it shouldn't crash): It should throw whatever error it was expected to throw.

json-to-shex doesn't recognize Shape.expression property

Using [email protected] from npm.

When I run shex-to-json on
{ "type": "Schema", "shapes": [ { "type": "Shape", "expression": { "type": "TripleConstraint", "predicate": "http://schema.example/#empID", "valueExpr": { "type": "NodeConstraint", "datatype": "http://www.w3.org/2001/XMLSchema#integer" } } } ] }
(Example reduced from a sample in ShEx 2.1 spec.)
I get:
aborting: Error: error parsing JSON file://C:\path\to\shex\example-shex.json: Error: unknown property: "expression" in ShapeDecl: {"type":"Shape","expression":{"type":"TripleConstraint","predicate":"http://schema.example/#empID","valueExpr":{"type":"NodeConstraint","datatype":"http://www.w3.org/2001/XMLSchema#integer"}}} at parseShExJ (C:\path\to\node_modules\@shexjs\loader\shex-loader.js:280:18) at loadParseMergeSchema (C:\path\to\node_modules\@shexjs\loader\shex-loader.js:189:22)
Expected ShExC output without error.
Same error from same input on https://rawgit.com/shexSpec/shex.js/main/packages/shex-webapp/doc/shex-simple.html

Can't use local object to be validated

I didn't manage to use a local object to be validated. This works:

ShEx.Loader.load([validationShape], [], [], [dataURL]).then(function (loaded) {
  var db = ShEx.Util.makeN3DB(loaded.data);
  var validator = ShEx.Validator.construct(loaded.schema, { results: "api" });
  var result = validator.validate(db, [{node: dataID, shape: shapeURL}]);
  return result;
}).catch(e => console.error(e));

But this throw an error:

ShEx.Loader.load([validationShape], [], [], [dataObject]).then(function (loaded) {
  var db = ShEx.Util.makeN3DB(loaded.data);
  var validator = ShEx.Validator.construct(loaded.schema, { results: "api" });
  var result = validator.validate(db, [{node: dataID, shape: shapeURL}]);
  return result;
}).catch(e => console.error(e));

Throw TypeError: Cannot use 'in' operator to search for 'productions' in undefined

Here is dataObject:

{
  title: "Title test",
  text: "Text test", 
  @id: "http://127.0.0.1:8000/conversations/7/"
}

Am I doing something wrong?

Should use `@rdfjs/types` rather than `rdf-js` and move to dependency

What broken?

Typescript types

Version

No response

What happened (e.g., it crashed)?

Usage of @types/rdf-js should be @rdfjs/types instead. See https://github.com/rdfjs/types?tab=readme-ov-file#what-about-typesrdf-js.

Secondly, it should be a dependency in cases where the types are used as part of the API that is exported by the library in order to avoid downstream errors like the following.

$ npm i

> @jeswr/[email protected] prepare
> tsc

node_modules/@shexjs/eval-validator-api/src/validator-api.ts:6:33 - error TS2307: Cannot find module 'rdf-js' or its corresponding type declarations.

6 import {Quad as RdfJsQuad} from "rdf-js";
                                  ~~~~~~~~

node_modules/@shexjs/term/src/shex-term.ts:38:33 - error TS2307: Cannot find module 'rdf-js' or its corresponding type declarations.

38 import {Term as RdfJsTerm} from 'rdf-js';
                                   ~~~~~~~~

node_modules/@shexjs/validator/src/shex-validator.ts:18:44 - error TS2307: Cannot find module 'rdf-js' or its corresponding type declarations.

18 import type {Quad, Term as RdfJsTerm} from 'rdf-js';
                                              ~~~~~~~~

node_modules/@shexjs/validator/src/shex-xsd.ts:4:38 - error TS2307: Cannot find module 'rdf-js' or its corresponding type declarations.

4 import type {Term as RdfJsTerm} from 'rdf-js';
                                       ~~~~~~~~


Found 4 errors in 4 files.

Errors  Files
     1  node_modules/@shexjs/eval-validator-api/src/validator-api.ts:6
     1  node_modules/@shexjs/term/src/shex-term.ts:38
     1  node_modules/@shexjs/validator/src/shex-validator.ts:18
     1  node_modules/@shexjs/validator/src/shex-xsd.ts:4
npm ERR! code 2
npm ERR! path /home/jeswr/Documents/GitHub/jeswr/reasoning-test/shacl2shex
npm ERR! command failed
npm ERR! command sh -c tsc

npm ERR! A complete log of this run can be found in: /home/jeswr/.npm/_logs/2024-04-12T18_34_03_469Z-debug-0.log

What should have happened instead (e.g., it shouldn't crash)?

No response

How can we reproduce this error?

No response

Infinite Loop on Validation (Alpha24)

Description of problem

The following schema and turtle causes and infinite loop on validation.

URL to affected spec or repo: https://github.com/shexjs/shex.js

What happened (e.g., it crashed)?: When running the validate method, the programm seems to either enter an infinite loop, or takes so long that it causes web-browser timeouts.

Expected behavior (e.g., it shouldn't crash): The RDF should be validated in an acceptable amount of time.

Optional, steps to reproduce:

Validate the following:

Mapping:

<https://wikifactory.com/%2Bfablabbenfica/merry-christmas-tree/c1cfebceed36b2998fea987ad1b0834192da975f/>@<https://github.com/OPEN-NEXT/OKH-LOSH/raw/master/OKH-LOSH-Shapes.ttl#Module>

Turtle:

@prefix : <https://wikifactory.com/%2Bfablabbenfica/merry-christmas-tree/c1cfebceed36b2998fea987ad1b0834192da975f/> .
@prefix okh: <https://github.com/OPEN-NEXT/OKH-LOSH/raw/master/OKH-LOSH.ttl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

:Project a okh:Module ;
    rdfs:label "Merry Christmas Tree" ;
    okh:dataSource "wikifactory.com" ;
    okh:documentationLanguage "en" ;
    okh:function "A quick project that generated our Sesons Greeting postcard. This publication is part of it. Following the spirit of our membership in the Distributed Design Market Platform and the support we got this year from Investwood - Valchromat, here is our small contribuition to Makers Christmas." ;
    okh:hasComponent :Fabxmastreev22 ;
    okh:hasImage :Image ;
    okh:hasReadme :Readme ;
    okh:licensor "André Rocha" ;
    okh:organisation "FabLab Benfica" ;
    okh:release <https://wikifactory.com/+fablabbenfica/merry-christmas-tree/v/c1cfebc> ;
    okh:repo <https://wikifactory.com/+fablabbenfica/merry-christmas-tree> ;
    okh:repoHost "wikifactory.com" ;
    okh:spdxLicense <https://spdx.org/licenses/CC0-1.0> ;
    okh:uploadMethod "auto" ;
    okh:version "c1cfebceed36b2998fea987ad1b0834192da975f" ;
    okh:versionOf <https://wikifactory.com/+fablabbenfica/merry-christmas-tree> .

:Fabxmastreev22 a okh:Part ;
    rdfs:label "FabXmasTree_v22" ;
    okh:documentationLanguage "en" ;
    okh:licensor "André Rocha" ;
    okh:source :Fabxmastreev22_source ;
    okh:spdxLicense <https://spdx.org/licenses/CC0-1.0> .

:Fabxmastreev22_source a okh:SourceFile ;
    rdfs:label "Source File of FabXmasTree_v22 of Merry Christmas Tree c1cfebceed36b2998fea987ad1b0834192da975f" ;
    okh:fileFormat "STEP" ;
    okh:fileUrl <https://wikifactory-prod-uploads.oss-accelerate.aliyuncs.com/31171/fabxmastree_v22.step> ;
    okh:permaURL <https://wikifactory-prod-uploads.oss-accelerate.aliyuncs.com/31171/fabxmastree_v22.step> .

:Image a okh:Image ;
    rdfs:label "Image of Merry Christmas Tree c1cfebceed36b2998fea987ad1b0834192da975f" ;
    okh:fileFormat "PNG" ;
    okh:fileUrl <https://wikifactory-prod-uploads.oss-accelerate.aliyuncs.com/31171/creditos_en_wikifactory-1c883.png> ;
    okh:permaURL <https://wikifactory-prod-uploads.oss-accelerate.aliyuncs.com/31171/creditos_en_wikifactory-1c883.png> .

:Readme a okh:Readme ;
    rdfs:label "Readme of Merry Christmas Tree c1cfebceed36b2998fea987ad1b0834192da975f" ;
    okh:fileFormat "MD" ;
    okh:fileUrl <https://wikifactory-prod-uploads.oss-accelerate.aliyuncs.com/31171/readme-edfa0.md> ;
    okh:permaURL <https://wikifactory-prod-uploads.oss-accelerate.aliyuncs.com/31171/readme-edfa0.md> .

Schema:

# ----------------------------------------------------
# Shex (https://shex.io) shapes based on the Open Know-How Speciication
# (https://github.com/OPEN-NEXT/OKH-LOSH/raw/master/OKH-LOSH.ttl)
# ----------------------------------------------------

PREFIX okhs: <https://github.com/OPEN-NEXT/OKH-LOSH/raw/master/OKH-LOSH-Shapes.ttl#>
PREFIX okh: <https://github.com/OPEN-NEXT/OKH-LOSH/raw/master/OKH-LOSH.ttl#>
PREFIX okshwa: <https://github.com/OPEN-NEXT/OKH-LOSH/raw/master/OKH-LOSH.ttl/oshwa=#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX schema: <https://schema.org/>
PREFIX otrl: <https://github.com/OPEN-NEXT/OKH-LOSH/raw/master/OTRL.ttl#>
PREFIX otrls: <https://github.com/OPEN-NEXT/OKH-LOSH/raw/master/OTRL-shapes.ttl#>

# THINGS TO NOTE
# "organization" is spelled with a "z" in the OWL, but with an "s" in most examples
# "FileFormat", "FileUrl", and "permaURL" are not in the OWL

# ----------------------------------------------------
# Component
# ----------------------------------------------------
okhs:Component EXTRA a {
  $okhs:ComponentShape (
    a [ okh:Component ]?
      // rdfs:comment "Either a module (MOSH) or Part (POSH); more component types may be added in the future";
    rdfs:label xsd:string?
      // rdfs:comment "Label for this object";
    okh:uploadMethod xsd:string?
      // rdfs:comment "e.g. auto (fully integrated platforms) or manifest file (for connected platforms)";
    okh:compilesWith IRI*
      // rdfs:comment "complies with a technical standard";
    okh:hasImage @okhs:Image*
      // rdfs:comment "links to the corresponding Image";
    okh:relatedTsDC IRI*
      // rdfs:comment "Identifier for the applying Technology-specific Documentation Criteria according to DIN SPEC 3105-1, e.g. `tsdc:3DP`";
  )
}

okhs:Module EXTRA a {
  $okhs:ModuleShape (
    &okhs:ComponentShape;
    a [okh:Module]?
      // rdfs:comment "Module of Open Source Hardware (MOSH)";
    okh:dataSource xsd:string?
      // rdfs:comment "platform, where the crawler found the metadata (e.g. GitHub, Wikifactory)";
    okh:repoHost xsd:string?
      // rdfs:comment "platform, where the OSH documentation is located (e.g. GitLab, Wikifactory or any self-hosted website or wiki)";
    okh:repo @okhs:WebsiteURL?
      // rdfs:comment "URL to the place where development happens (typically the repository) following this link people shall be able to contribute to the development (reporting issues, suggesting changes, connecting to the team etc.)";
    okh:repoSnapshot @okhs:WebsiteURL?
      // rdfs:comment "LOSH-Krawler takes the commit hash from the version tag and creates this permalink";
    okh:version xsd:string?
      // rdfs:comment "version of this Component, preferably in the semantic versioning scheme (semver.org)";
    okh:forkOf IRI?
      // rdfs:comment "A resource from which this work is derived or from which it is a modification or adaption.";
    okh:versionOf @okhs:Module*
      // rdfs:comment "connects specific versions of Modules with their versionless superclass";
    okh:documentationLanguage xsd:string?
      // rdfs:comment "IETF language tag following the BCP 47 standard e.g. en-GB denotes the language of the documentation for the component subject";
    okh:licensor xsd:string?
      // rdfs:comment "organization/individual behind the hardware design (holder of intellectual property)";
    okh:organization IRI?
      // rdfs:comment "organization representing (most) contributors of this project";
    okh:spdxLicense IRI?
      // rdfs:comment "view complete list under https://spdx.org/licenses/";
    okh:alternativeLicense IRI*
      // rdfs:comment "URL to legal code of a license without SPDX identifier, hence OSHWA-compliance is to be checked manually";
    okh:technologyReadinessLevel @otrls:OTRL?
      // rdfs:comment "Technology Readiness Level (TRL) using the OTRL definitions";
    okh:documentationReadinessLevel @otrls:Odrl?
      // rdfs:comment "Documentation Readiness Level (DLR) using the ODRL definitions";
    okh:attestation IRI*
      // rdfs:comment "permanent URL to evidence of compliance (OSHWA, FSF, DIN SPEC 3105)";
    okh:hasPublication IRI*
      // rdfs:comment "design files of this OSH modules have been peer reviewed in a scientific publication";
    okh:cpcPatentClass IRI*
      // rdfs:comment "International Patent Classification (IPC)";
    # TODO: Might not actually be a string
    okh:function xsd:string?
      // rdfs:comment "functional description, e.g. what it actually does, what problem it solves, for whom, under which conditions etc. so if you wish that someone finds & uses your okh specifically e.g. for COVID-19-crisis response, include relevant keywords in this field optional: description of input, output and interfaces";
    okh:hasReadme @okhs:Readme*
      // rdfs:comment "links to the corresponding Readme";
    okh:hasContributionGuide @okhs:ContributionGuide*
      // rdfs:comment "links to the corresponding Contribution Guide";
    okh:hasBoM @okhs:BoM*
      // rdfs:comment "links to the corresponding Bill of Materials";
    okh:hasComponent @okhs:Part*
      // rdfs:comment "links to parts of the module";
    (okh:usesModule @okhs:Module* | okh:useModule @okhs:WebsiteURL*)
      // rdfs:comment "refers to a *release*/snapshot of an (external) OSH Module used in this design (should also appear in the BoM)";
    okh:functionalMetadata xsd:string*
      // rdfs:comment "Metadata addressing functionality, such as dimensions, material, weight, RPM,… (not standardised)";
    okh:productionMetadata IRI*
      // rdfs:comment "production-relevant metadata, such as material, manufacturing technology, outer dimensions, smallest tolerance, finest surface roughness";
    okh:hasManifestFile @okhs:ManifestFile*
      // rdfs:comment "has manifest file";
    okh:timestamp xsd:dateTime*
      // rdfs:comment "following ISO 8601";
    okh:source @okhs:SourceFile*
      // rdfs:comment "relative link to a source file";
    okh:export @okhs:ExportFile*
      // rdfs:comment "URL to a (generated) exported source file";
    okh:auxiliary @okhs:AuxiliaryFile*
      // rdfs:comment "reference to an auxiliary file";
    okh:hasUserManual @okhs:UserManual*
      // rdfs:comment "has user manual";
    okh:hasManufacturingInstructions @okhs:ManufacturingInstructions*
      // rdfs:comment "has Manufacturing Instructions";
    okh:hasSoftware @okhs:Software*
      // rdfs:comment "has Software";
    okh:release IRI*
      // rdfs:comment "URL to release";
    okshwa:primaryType xsd:string?
      // rdfs:comment "primary category as stated at OSHWA - possilbe values: 3D Printing, Agriculture, Arts, Education, Electronics, Enclosure, Environmental, Home Connection, IOT, Manufacturing, Other, Robotics, Science, Sound, Space, Tool, Wearables";
    okshwa:additionalType xsd:string*
      // rdfs:comment "additional category as stated at OSHWA";
    okshwa:hardwareLicense IRI?
      // rdfs:comment "harward license as stated at OSHWA";
    okshwa:softwareLicense IRI?
      // rdfs:comment "sotware license as stated at OSHWA";
    okshwa:documentationLicense IRI?
      // rdfs:comment "documentation license as stated at OSHWA";
    okshwa:country xsd:string?
      // rdfs:comment "origin (country) as stated at OSHWA";
    okshwa:certificationDate xsd:date?
      // rdfs:comment "certification date as state at OSHWA"
  )
}

okhs:Part EXTRA a {
  $okhs:PartShape (
    &okhs:ComponentShape;
    a [okh:Part]?
      // rdfs:comment "Piece of Open Source Hardware (POSH)";
    okh:forkOf IRI?
      // rdfs:comment "fork of" ;
    okh:documentationLanguage xsd:string?
      // rdfs:comment "IETF language tag following the BCP 47 standard e.g. en-GB denotes the language of the documentation for the component subject";
    okh:productionMetadata IRI*
      // rdfs:comment "production-relevant metadata, such as material, manufacturing technology, outer dimensions, smallest tolerance, finest surface roughness";
    okh:smallestToleranceClass IRI?
      // rdfs:comment "smallest tolerance class (following ISO 286)";
    okh:hasManifestFile @okhs:ManifestFile*
      // rdfs:comment "has manifest file";
    okh:source @okhs:SourceFile*
      // rdfs:comment "relative link to a source file";
    okh:export @okhs:ExportFile*
      // rdfs:comment "URL to a (generated) exported source file";
    okh:auxiliary @okhs:AuxiliaryFile*
      // rdfs:comment "reference to an auxiliary file";
    okh:hasManufacturingInstructions @okhs:ManufacturingInstructions*
      // rdfs:comment "has Manufacturing Instructions";
  )
}

okhs:Software EXTRA a {
  $okhs:SoftwareShape (
    &okhs:ComponentShape;
    a [okh:Software]?
      // rdfs:comment "Software (including firmware) needed to run & use the OSH";
    okh:release IRI*
      // rdfs:comment "URL to release";
    okh:installationGuide xsd:string*
      // rdfs:comment "Installation Guide";
  )
}

okhs:Reference EXTRA a {
  $okhs:ReferenceShape (
    a [okh:Reference]?
      // rdfs:comment "unambiguous reference";
    rdfs:label xsd:string?
      // rdfs:comment "Label for this object";
  )
}

okhs:WebsiteURL EXTRA a {
  $okhs:WebsiteURLShape (
    &okhs:ReferenceShape;
    a [okh:WebsiteUrl]?
      // rdfs:comment "Website URL";
    schema:url xsd:string
      // rdfs: "URL of the item.";
  )
}

okhs:Publication EXTRA a {
  $okhs:PublicationShape (
    a [okh:Publication]?
      // rdfs:comment "_scientific_ (that is: peer reviewed) publication that _contains_ the design files";
    okh:doi xsd:string?
      // rdfs:comment "this publication has a digital object identifier (DOI)";
    rdfs:label xsd:string?
      // rdfs:comment "Label for this object";
  )
}

okhs:Standard EXTRA a {
  $okhs:StandardShape (
    a [okh:Standard]?
      // rdfs:comment "official standard used in the _design_ (not e.g. DIN SPEC 3105-1)";
    okh:standardID xsd:string?
      // rdfs:comment "Document Identifier for the technical Standard";
    rdfs:label xsd:string?
      // rdfs:comment "Label for this object";
  )
}

okhs:File EXTRA a {
  $okhs:FileShape (
    a [okh:File]?
      // rdfs:comment "File";
    rdfs:label xsd:string?
      // rdfs:comment "Label for this object";
    okh:fileFormat xsd:string?
      // rdfs:comment "File extension. For example 'JPG'";
    okh:fileUrl IRI
      // rdfs:comment "The url of the file";
    okh:permaURL IRI?
      // rdfs:comment "A permanent url for the file";
  )
}

okhs:ManifestFile EXTRA a {
  $okhs:ManifestFileShape (
    &okhs:FileShape;
    a [okh:ManifestFile]?
      // rdfs:comment "file holding the metadata";
    okh:okhv xsd:string?
      // rdfs:comment "version of OKH specification the metadata is following (different version → different data fields)";
  )
}

okhs:Readme EXTRA a {
  $okhs:ReadmeShape (
    &okhs:FileShape;
    a [okh:Readme]?
  )
}

okhs:ContributionGuide EXTRA a {
  $okhs:ContributionGuideShape (
    &okhs:FileShape;
    a [okh:ContibutionFile]?
  )
}

okhs:Image EXTRA a {
  $okhs:ImageShape (
    &okhs:FileShape;
    a [okh:Image]?
  )
}

okhs:BoM EXTRA a {
  $okhs:BoMShape (
    &okhs:FileShape;
    a [okh:BoM]?
  )
}

okhs:SourceFile EXTRA a {
  $okhs:SourceFileShape (
    &okhs:FileShape;
    a [okh:SourceFile]?
  )
}

okhs:ExportFile EXTRA a {
  $okhs:ExportFileShape (
    &okhs:FileShape;
    a [okh:ExportFile]?
  )
}

okhs:AuxiliaryFile EXTRA a {
  $okhs:AuxiliaryFileShape (
    &okhs:FileShape;
    a [okh:AuxiliaryFile]?
  )
}

okhs:ManufacturingInstructions EXTRA a {
  $okhs:ManufacturingInstructionsShape (
    &okhs:FileShape;
    a [okh:ManufacturingInstructions]?
  )
}

okhs:UserManual EXTRA a {
  $okhs:UserManualShape (
    &okhs:FileShape;
    a [okh:UserManual]?
  )
}

okhs:OuterDimensions EXTRA a {
  $okhs:OuterDimensionsShape (
    a [okh:OuterDimensions]?
      // rdfs:comment "outer dimensions of a module or part";
    okh:openScad xsd:string*
      // rdfs:comment "material";
    okh:unit xsd:string*
      // rdfs: "mm, cm, m, g, kg";
    rdfs:label xsd:string?
      // rdfs:comment "Label for this object";
  )
}

okhs:Mass EXTRA a {
  $okhs:MassShape (
    a [okh:Mass]?
      // rdfs:comment "mass of a module or part";
    okh:unit xsd:string*
      // rdfs: "mm, cm, m, g, kg";
    okh:value xsd:decimal*
      // rdfs:comment "value";
    rdfs:label xsd:string?
      // rdfs:comment "Label for this object";
  )
}

otrls:OTRL EXTRA a {
  $otrls:OTRLShape (
    a [otrl:OTRL]?
      // rdfs:comment "Technology Readiness Level for open source hardware";
    otrl:goal xsd:string?
      // rdfs:comment "Goal or purpose of this OTRL/ODRL";
    otrl:exitCriteria xsd:string?
      // rdfs:comment "Criteria to exit this OTRL for the next OTRL; inspired by: https://www.nasa.gov/pdf/458490main_TRL_Definitions.pdf";
    rdfs:label xsd:string?
      // rdfs:comment "Label for this object";
  )
}

otrls:Odrl EXTRA a {
  $otrls:OdrlShape (
    a [otrl:Odrl]?
      // rdfs:comment "Documentation Readiness Level for open source hardware";
    otrl:goal xsd:string?
      // rdfs:comment "Goal or purpose of this OTRL/ODRL";
    otrl:exitCriteria xsd:string?
      // rdfs:comment "Criteria to exit this OTRL for the next OTRL; inspired by: https://www.nasa.gov/pdf/458490main_TRL_Definitions.pdf";
    rdfs:label xsd:string?
      // rdfs:comment "Label for this object";
  )
}

Unable to build the visitor library from npm

Description of problem

I'm trying to use the visitor library but when I'm installing it from npm I'm getting the errors printed bellow
URL to affected spec or repo:
https://github.com/shexjs/shex.js/tree/main/packages/shex-visitor#readme

What happened (e.g., it crashed)?:

node_modules/@shexjs/visitor/shex-visitor.d.ts:6:13 - error TS2305: Module '"shexj"' has no exported member 'exclusion'.

6     EachOf, exclusion,
              ~~~~~~~~~
node_modules/@shexjs/visitor/shex-visitor.d.ts:20:23 - error TS2304: Cannot find name 'Schema'.
20   visitSchema(schema: Schema, ...args: any[]): any;
                         ~~~~~~
node_modules/@shexjs/visitor/shex-visitor.d.ts:56:24 - error TS2304: Cannot find name 'nodeKind'.
56     visitNodeKind: (v: nodeKind, ...args: any[]) => any;
                          ~~~~~~~~
node_modules/@shexjs/visitor/shex-visitor.d.ts:81:21 - error TS2552: Cannot find name 'Shape'. Did you mean 'ShapeOr'?
81   visitShape(shape: Shape, ...args: any[]): any;
                       ~~~~~
node_modules/@shexjs/visitor/shex-visitor.d.ts:92:25 - error TS2552: Cannot find name 'tripleExpr'. Did you mean 'tripleExprRef'?
92   visitTripleExpr(expr: tripleExpr, ...args: any[]): any;
                           ~~~~~~~~~~
Found 5 errors in the same file, starting at: node_modules/@shexjs/visitor/shex-visitor.d.ts:6

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Expected behavior (e.g., it shouldn't crash):

I should be able to install it.

Parse error causes server to abort

Invocation:

./bin/validate --serve http://localhost:4290/validate -x ~/Development/git/crDDI/validator/shex/account.shex --regex-module nfax-val-1err --duplicate-shape replace

When we feed the server a poorly formed ShEx document we get:

Error: file:///Users/mrf7578/Development/git/shexSpec/shex.js/rest/uploads/upload_52dbf1bbe6d9bfb0da04075f25e174ad(103): Parse error on line 102:
...cident occurred    see
----------------------^
Expecting '!', 'IRIREF', 'PNAME_NS', '}', '&', '|', '(', ')', '^', 'a', 'PNAME_LN', got 'invalid character s'
...cident occurred    see
----------------------^
    at parseShExC (/Users/mrf7578/Development/git/shexSpec/shex.js/lib/ShExLoader.js:102:54)
    at /Users/mrf7578/Development/git/shexSpec/shex.js/lib/ShExLoader.js:82:9
    at tryCallTwo (/Users/mrf7578/Development/git/shexSpec/shex.js/node_modules/promise/lib/core.js:45:5)
    at doResolve (/Users/mrf7578/Development/git/shexSpec/shex.js/node_modules/promise/lib/core.js:200:13)
    at new Promise (/Users/mrf7578/Development/git/shexSpec/shex.js/node_modules/promise/lib/core.js:66:3)
    at /Users/mrf7578/Development/git/shexSpec/shex.js/lib/ShExLoader.js:81:14
    at /Users/mrf7578/Development/git/shexSpec/shex.js/lib/ShExLoader.js:61:14
    at tryCallOne (/Users/mrf7578/Development/git/shexSpec/shex.js/node_modules/promise/lib/core.js:37:12)
    at /Users/mrf7578/Development/git/shexSpec/shex.js/node_modules/promise/lib/core.js:123:15
    at flush (/Users/mrf7578/Development/git/shexSpec/shex.js/node_modules/asap/raw.js:50:29)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
>

Value sets with language tags not working without a tilde

Date: Sun, 14 May 2017 16:57:31 +0300
From: Janis Kajaks <[email protected]>
To: [email protected]
Subject: ShExC schema generator tool for evaluation
Content-Type: text/plain; charset="UTF-8"
Archived-At: <http://www.w3.org/mid/CADt6OBMnKLLyfiPCRU+0dV0=wtavFpeXPyASxhdj+qrJAd-hWw@mail.gmail.com>

...

In order to test the tool, I used this online validator:
http://rawgit.com/shexSpec/shex.js/master/doc/shex-simple.html and I
found one test case which was a bit confusing – in ShEx primer
(http://shex.io/shex-primer/index.html#value-sets ) it’s said that you
can use IRIs, literals or language tags for value sets, and a value
set with language tag could look something like this:

my:IssueShape {
  ex:label [@en]
}

But unfortunately it does not work in the chosen validator, it works
only if I append a tilde “~” like this:
my:IssueShape {
  ex:label [@en~]
}

Could you, please, comment on why it works like this

importing external shex replace the schema.start value

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

failing recursive shape in EXTRA counts in cardinality

Data 1 fails the cardinality on <p> in schema 1 when in fact there's only one <p> matching <p> { <value> [1] }:

Schema 1:

<S> EXTRA <p> { <p> { <value> [1] } }

Data 1:

<s> <p> [ <value> 1], [ <value> 2 ].

one-liner:
./bin/validate -x 'data:text/shex,<S> EXTRA <p> { <p> { <value> [1] } }' -s S -d 'data:text/turtle,<s> <p> [ <value> 1], [ <value> 2 ].' -n s

can't parse Wikidata EntitySchema shex with shex-to-json

the following command

shex-to-json  https://www.wikidata.org/wiki/Special:EntitySchemaText/E233

fails with this error:

aborting: Error: error parsing JSON https://www.wikidata.org/wiki/Special:EntitySchemaText/E233: SyntaxError: Unexpected token P in JSON at position 0
    at parseShExJ (/some/project/node_modules/shex/lib/ShExLoader.js:274:14)
    at /some/project/node_modules/shex/lib/ShExLoader.js:103:14
    at tryCatcher (/some/project/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/some/project/node_modules/bluebird/js/main/promise.js:510:31)
    at Promise._settlePromiseAt (/some/project/node_modules/bluebird/js/main/promise.js:584:18)
    at Promise._settlePromises (/some/project/node_modules/bluebird/js/main/promise.js:700:14)
    at Async._drainQueue (/some/project/node_modules/bluebird/js/main/async.js:123:16)
    at Async._drainQueues (/some/project/node_modules/bluebird/js/main/async.js:133:10)
    at Immediate.Async.drainQueues (/some/project/node_modules/bluebird/js/main/async.js:15:14)
    at processImmediate (internal/timers.js:461:21)

It seems it can't parse the PREFIX keyword(?). This shex doesn't seem to be a problem for the python library. Any clue on what's wrong?

Invalid shape ID when parsing with baseIRI

When parsing the shape at http://shapes.pub/ns/medical-record/shex#MedicalRecordShape with the following code:

const parser = shexParser.construct('http://shapes.pub/ns/medical-record/shex#MedicalRecordShape');
const schema = parser.parse(data);

the first shape has the id "https://shapes.pub/ns/medical-record/MedicalRecordShape", while it is expected to be "https://shapes.pub/ns/medical-record/shex#MedicalRecordShape".

I guess something may be going wrong with relative IRI to base resolution when fragments are present.

catch shex.Loader.load() errors

Hi,
I'd like to know if there is a way to catch shex.Loader.load() errors.
or parser errors.
I'm trying to generate forms-ui from a shex shape as discussed here
https://forum.solidproject.org/t/from-shape-to-form-experiments-with-shex-shacl/2027
based on Ruben' post
https://forum.solidproject.org/t/blog-post-shaping-linked-data-apps/1914 and more https://ruben.verborgh.org/blog/2019/06/17/shaping-linked-data-apps/

So I've tried to parse .shex myself but it's hard, so I tried shex.js
and it's working quite good as you can see here https://scenaristeur.github.io/spoggy-simple/testform.html

But I've got some mistake with two of my shex. Perharps are they malformatted but I don't know what is the mistake (the manner I implemente the Choice ? )

For all the shex, it runs, but when I choose
https://holacratie.solid.community/public/Schema/purpose.shex or https://holacratie.solid.community/public/Schema/domaine.shex

Nothing happens,

I've tried to test the loaded.schema https://github.com/scenaristeur/spoggy-simple/blob/020548ff707c6f171d1dcf7d72788cabc0d91a57/testform.html#L93

but nothing happens .

So I wonder if it could be possible to catch a loading/parsing error .

  • if you have an idea with what could be wrong in purpose.shex & domain.shex, I'd be really thankfull
    ;-)

Tests failing locally

I'm sorry I don't know how to interpret these further, but downloading the library today and running the commands as described: cd node_modules/shex && npm install && npm test I'm seeing the tests fail locally. I've attached the results. Any other help here appreciated.

2020-08-15-test_results.txt

Failing to run your Readme example

Hi, I am failing to run your README example:

const shexc = "http://shex.io/examples/Issue.shex";
const data = "http://shex.io/examples/Issue1.ttl";
const node = "http://shex.io/examples/Issue1";

const ShExLoader = require("@shexjs/loader");
const { ctor: RdfJsDb } = require('@shexjs/neighborhood-rdfjs')
const {ShExValidator} = require("@shexjs/validator");
ShExLoader.load({shexc: [shexc]}, {turtle: [data]}).then(function (loaded) {
    var db = RdfJsDb(loaded.data);
    var validator = new ShExValidator(loaded.schema, db, { results: "api" });
    var result = validator.validate([{node: node, shape: ShExValidator.Start}]);
    console.log(result);
});

It says there is no method .load on ShExLoader. I am running this using node script.js after having npm install the three dependencies.

ShEx Loader + Validator example in Readme is broken

The example given in the Readme for how to use the Loader and Validator, seems broken. It throws the following error:

Uncaught (in promise) TypeError: db.getNeighborhood is not a function
    at ShExValidator_constructor._validateShape (shex-webapp-webpack.js:51591)
    at ShExValidator_constructor._validateShapeExpr (shex-webapp-webpack.js:51539)
    at ShExValidator_constructor.validate (shex-webapp-webpack.js:51505)
    at shex-test.html:19

It seems to be thrown at https://github.com/shexSpec/shex.js/blob/17756428852d9abb1d5242f539675265ea38395a/packages/shex-core/lib/ShExValidator.js#L474

I also receive this error in the version build with the npm package, where it is thrown at https://github.com/shexSpec/shex.js/blob/6709a8dc8ca9e19397aeea52cc898ec2e31d6cb7/packages/shex-core/lib/ShExValidator.js#L583

You can reproduce this by putting the following html file next to shex-simple.html in packages/shex-webapp/doc/ and opening it.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Minimal failing example</title>
</head>
<body>
<script src="../browser/shex-webapp-webpack.js"></script>
<script>

	var shex = ShExWebApp; // @@ rename globally
	var shexc = "http://shex.io/examples/Issue.shex";
	var shape = "http://shex.io/examples/IssueShape";
	var data = "http://shex.io/examples/Issue1.ttl";
	var node = "http://shex.io/examples/Issue1";

	shex.Loader.load([shexc], [], [data], []).then(function (loaded) {
		console.log(shex.Validator.construct(loaded.schema).validate(loaded.data, node, shape));
	});
</script>
</body>
</html>

Am I doing something wrong?

ShexJison error can't resolve 'fs' on solid-sdk-forms

Windows 10, node v12.18.1
The second part of my issue seems to come from shexjs ?
inrupt/solid-sdk-forms#130 (comment)

I tried to install @shexjs/core & @shexjs/parser manually as dep of my project, but now, when i run 'npm run dev' with a webpack conf, i got


   ERROR in ./node_modules/@shexjs/parser/lib/ShExJison.js
   Module not found: Error: Can't resolve 'fs' in 'C:\Users\Smag\Documents\dev\shighl-elements\node_modules\@shexjs\parser\lib'
    @ ./node_modules/@shexjs/parser/lib/ShExJison.js 1852:17-30
    @ ./node_modules/@shexjs/parser/shex-parser.js
    @ ./node_modules/@inrupt/solid-sdk-forms/dist/solid-forms.es5.js
    @ ./src/shighl-crud.js
i 「wdm」: Failed to compile.
Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\hiberfil.sys'
Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\pagefile.sys'
Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\swapfile.sys'

Duplicate shape option not specific enough

The "--duplicate-shape fred" option (I guess one string is as good as another) causes the parser to ignore duplicate shapes across and within shape definition files. We need an option that causes the parser to ignore duplicates if we happen to send the same or similar shape definition across two invocations. We do not, however, want to ignore two definitions of the same shape within the same same call.

Suggestion: the caching of definitions should be changed to an "opt in" approach. Don't cache a shape definition unless the caller specifically says "I want you to hang on to this".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.