o-development / ldo-legacy

Linked Data Objects
Other
19 stars 2 forks source link

How does LDO handle polymorphic / variant types? #2

Closed ianconsolata closed 1 year ago

ianconsolata commented 1 year ago

We use a hierarchy of RDF:Class predicates to indicate various levels of specificity. We expect all subjects in a resource to with RDF class ex:Item to have a certain set of base properties like dcterms:description, dcterms:title, etc. We also have specific RDF subclasses like ex:Image, which we use to indicate the presence of additional expected properties like dcterms:format. It looks like such a heirarchy might be possible to model in shex, but I am not sure how that would map to Typescrit.

jaxoncreed commented 1 year ago

Right now, ShEx does not have an "Extend" function. Eric is working on implementing it, but for now, there's a workaround. See how I handle it for ActivityPub: https://gist.github.com/jaxoncreed/a09ed0e388cacc37af3679d4b2c98023. In the example here (https://gist.github.com/jaxoncreed/a09ed0e388cacc37af3679d4b2c98023#file-activitystreamsshapes-shex-L137-L139) I'm essentially saying that sra:Activity extends sra:Object. It's a little messy because you need to make a new variable using the $ operator, but it works. Though, when you translate this to TypeScript, it won't use the extends keyword. Instead, it will simply copy all of the fields from Object into Activity. Once Eric implements "Extends" in ShEx, I'll be able to update the TypeScript compiler to utilize the extends keyword.