iovka / shex-java

Validation of Shape Expression Schemas
GNU Lesser General Public License v3.0
10 stars 6 forks source link

javadoc or examples #5

Open iovka opened 5 years ago

iovka commented 5 years ago

I should be able to use the API w/o knowing the code. For instance, I'm not able to create a ShapeExprer (i.e. its abstract syntax tree) because I do not know how to use the constructors, and which classes to use. In particular, the concrete syntax node constraints

ericprud commented 5 years ago

@hsolbrig did this with his python implementation. He automagically generates it from the JSG. It I recall, he had to loosen his parameter validation to allow creation of an empty ShapeAnd because he couldn't construct a circular shape bottom-up. Did I get that right, @hsolbrig?

<S> {
  :p1 @<S>
}
hsolbrig commented 5 years ago

Which API are you referring to, @iovka?

ShExJSG has a set of python classes that represent the AST but you still have to know how to use the constructors. I did something about 6 months back that I am beginning to think was a bad idea -- validating the arguments, or lack thereof, to the constructors. As a result, one can't construct an empty ShapeAnd and then append the ShapeExpr's after the fact -- one needs to supply at least 2 ShapeExprs to do the construction. This resulted in my having to add extra code to various ShEx generators (biolinkml for example) that I found to be a tad unasthetic. I may consider backing this out or providing a "permissive" option (which should be fairly easy...) to allow one to follow a slightly more logical path.

WRT to Eric's comment -- this doesn't apply to the API -- one can construct a TripleExpression with predicate :p1 and target a ShapeExprReference independent of whether the reference actually exists. The ShEx isn't checked for validity until one tries to run it.