Shex/Obsolete/Encoding of greedy matching

From Semantic Web Standards

Obsolete - please see ShEx Semantics

Currently used encoding for greedy matching

A rule group can be defined either as anonymous node are as named node, which can be included into another rulegroup(see ....) So the following example

ex:a { 
  ex:name xsd:string+
}
ex:b & ex:a { 
  ex:surname xsd:string+ 
} 
ex:c & ex:a { 
  ex:alias xsd:string+ 
} 

will be encoded as

ex:a a rs:ResourceShape ;
 rs:occurs rs:Exactly-one;
 rs:property [ a se:ValueProperty ;
   rs:occurs rs:Exactly-one;
   rs:name "name";
   rs:propertyDefinition ex:name;
   rs:valueType xsd:string ;
 ].
ex:b a rs:ResourceShape ;
 rs:occurs rs:Exactly-one;
 se:subGroup ex:a; #just include the parent rule as subRule, which must also be satisfied
 rs:property [ a se:ValueProperty ;
   rs:occurs rs:Exactly-one;
   rs:name "surname";
   rs:propertyDefinition ex:surname;
   rs:valueType xsd:string ;
 ].
ex:c a rs:ResourceShape ;
 rs:occurs rs:Exactly-one;
 se:subGroup ex:a; #just include the parent rule as subRule, which must also be satisfied
 rs:property [ a se:ValueProperty ;
   rs:occurs rs:Exactly-one;
   rs:name "alias";
   rs:propertyDefinition ex:alias;
   rs:valueType xsd:string ;
 ].

The following encoding is used when its defined as VIRTUAL

VIRTUAL ex:a { 
  ex:name xsd:string+
}
ex:b & ex:a { 
  ex:surname xsd:string+ 
} 
ex:c & ex:a { 
  ex:alias xsd:string+ 
} 

will be encoded as

ex:a a rs:ResourceShape ;
  rs:occurs rs:Exactly-one;
  rs:property [ a se:ValueProperty ;
    rs:occurs rs:Exactly-one;
    rs:name "name";
    rs:propertyDefinition ex:name;
    rs:valueType xsd:string ;
  ]
  #Define VIRTUAL, by forcing it to comply to one of its 'child' shapes
  se:subGroup [ a se:OrRuleGroup ;
    rs:occurs        rs:Exactly-one; 
    se:subGroup        ex:b;
    se:subGroup        ex:c;
  ].
ex:b a rs:ResourceShape ;
  rs:occurs rs:Exactly-one;
  se:subGroup ex:a; #just include the parent rule as subRule, which must also be satisfied
  rs:property [ a se:ValueProperty ;
    rs:occurs rs:Exactly-one;
    rs:name "surname";
    rs:propertyDefinition ex:surname;
    rs:valueType xsd:string ;
  ].
 ex:c a rs:ResourceShape ;
  rs:occurs rs:Exactly-one;
  se:subGroup ex:a; #just include the parent rule as subRule, which must also be satisfied
  rs:property [ a se:ValueProperty ;
    rs:occurs rs:Exactly-one;
    rs:name "alias";
    rs:propertyDefinition ex:alias;
    rs:valueType xsd:string ;
  ].

Discussion

This solution has been chosen because

  1. all items in RDF are already referable
  2. no class semantics is included, SHEX level 1 defines basic shape expressions

An alternative solution would be to define a 'parent shape' property

ex:c se:superShape ex:a

but this would be in my opinion have a meaning similar to rdfs:subClassOf, which would add a semantic to meaning the reuse of rules. However, some cases of reuse it does not automatically means that it is a subClassOf its parent.