Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require top-level shape declarations #50

Open
labra opened this issue Jun 10, 2022 · 2 comments
Open

Require top-level shape declarations #50

labra opened this issue Jun 10, 2022 · 2 comments
Assignees

Comments

@labra
Copy link
Contributor

labra commented Jun 10, 2022

One feature that will be useful for ShEx is to have top-level shape definitions which refer to other shapes. For example:

<Human> @<Person>
<Person> { :name . }

This change would imply to add more ceremony to the ShExJ. For example:

{ "type": "Schema",
  "shapes": [
    { "type": "ShapeDecl", "id": "Human",
      "shapeExpr": {
        "type": "Shape",
        "expression": {
          "type": "TripleConstraint",
          "predicate": "http://example.org/name" } } },
    { "type": "ShapeDecl", "id": "Person",
      "shapeExpr": "Human" }
  ]
}

The changes for the ShExJ would look like:

The old ShExJ would represent it like this:

2.1

{
  "type": "Schema",
  "shapes": [
    { "type": "Shape",
      "id": "Human",
      "expression": {
        "type": "TripleConstraint",
        "predicate": "http://example.org/name"
      } }
  ]
}

The new ShExJ would look like:

2.2

{
  "type": "Schema",
  "shapes": [
    { "type": "ShapeDecl",
      "id": "Human",
      "shapeExpr": {
        "type": "Shape",
        "expression": {
          "type": "TripleConstraint",
          "predicate": "http://example.org/name"
        } } }
  ]
}

This is related with this PR: shexSpec/shexTest#49

In order to kepp backwards compatibility we may allow the old ShExJ in version 2.2 marking it as deprecated and adding it as an annex.

@ericprud
Copy link

ericprud commented Jun 10, 2022

The 2.2 version removes all the labeled* shapeExprs (and therefor has a simpler API):

Schema           {
  "@context":"http://www.w3.org/ns/shex.jsonld"?
  imports:[IRIREF+]?
  startActs:[SemAct+]? start:shapeExprOrRef? shapes:[ShapeDecl|ShapeExternal+]?
 }
ShapeDecl        { id:shapeExprLabel abstract:BOOL? specializes:[IRIREF+]? shapeExpr:shapeExpr }
ShapeExternal    { id:shapeExprLabel }

// Shape Expressions
shapeExpr        = ShapeOr | ShapeAnd | ShapeNot | NodeConstraint | Shape;
shapeExprOrRef   = shapeExpr | shapeExprRef;
ShapeOr          { shapeExprs:[shapeExprOrRef{2,}] }
ShapeAnd         { shapeExprs:[shapeExprOrRef{2,}] }
ShapeNot         { shapeExpr:shapeExprOrRef }
shapeExprRef     = shapeExprLabel ;
shapeExprLabel   = IRIREF | BNODE ;
NodeConstraint   { nodeKind:("iri"|"bnode"|"nonliteral"|"literal")? datatype:IRIREF? xsFacet* values:[valueSetValue+]? }

2.2 example with external:

{ "type": "Schema",
  "shapes": [
    { "type": "ShapeDecl", "id": "S1", "shapeExpr": {
        "type": "Shape", "expression": {
          "type": "TripleConstraint", "predicate": "http://example.org/name"
    } } },
    { "type": "ShapeExternal", "id": "S2" }
  ]
}

@ericprud
Copy link

Associated shexTest branch extends_top-level-ShapeDecl passes all JSG tests.

ericprud pushed a commit to shexjs/shex.js that referenced this issue Jun 16, 2022
@ericprud ericprud moved this to implemented in proposal manager Jun 27, 2022
@ericprud ericprud changed the title Add the possibility to define top-level shape declarations Require top-level shape declarations Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: implemented
Development

No branches or pull requests

2 participants