Conversation
A schema can hold a URI as a link to a resource or as data. A link is an IRI node. A URI reference held as data - a file path such as ./data/file.png, which may be relative - has to stay a literal: as an IRI, JSON-LD resolves it against the document base and it becomes a machine-specific absolute IRI. The way to declare the second is a type derived from string with uri: xsd:anyURI. The OWL generator already decides by type ancestry (is_xsd_anyuri_range): only uri, uriorcurie and the types derived from them are promoted to IRIs by --xsd-anyuri-as-iri. The other three RDF components keyed on the xsd:anyURI datatype instead, so such a type was an IRI in SHACL, in the JSON-LD context (with the flag) and in the RDF dumper, and a literal in OWL: - gen-shacl emits sh:nodeKind sh:Literal and sh:datatype xsd:anyURI for it - gen-jsonld-context keeps "@type": "xsd:anyURI" with --xsd-anyuri-as-iri, through the same predicate, for single ranges and any_of branches - the RDF dumper emits a typed literal for it, and resolves the type with inheritance, so a type derived from uri without a datatype of its own is an IRI node instead of a plain literal uri, uriorcurie and their derived types behave exactly as before. Signed-off-by: jdsika <carlo.van-driesten@vdl.digital>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes # — no issue covers this. Related: linkml#3221 (IRI nodes for
uriin the dumper andgen-shacl), linkml#3292 (--xsd-anyuri-as-iriforgen-owlandgen-jsonld-context).A schema can hold a URI either as a link to a resource or as data. A link is an IRI node. A URI reference held as data — a file path such as
./data/file.png, which may be relative — has to stay a literal: as an IRI, JSON-LD resolves it against the document base and it becomes a machine-specificfile:///home/<user>/...IRI.The way to declare the second is a type derived from
stringwithuri: xsd:anyURI.gen-owlalready decides by type ancestry (is_xsd_anyuri_range): onlyuri,uriorcurieand the types derived from them are promoted to IRIs by--xsd-anyuri-as-iri. The other three RDF components keyed on thexsd:anyURIdatatype, so such a type came out differently in each:gen-owlowl:DatatypeProperty, rangexsd:anyURIgen-shaclsh:nodeKind sh:IRIsh:nodeKind sh:Literal,sh:datatype xsd:anyURIgen-jsonld-context --xsd-anyuri-as-iri"@type": "@id""@type": "xsd:anyURI"URIRefLiteral(..., datatype=xsd:anyURI)All three now use the predicate
gen-owluses, for single ranges andany_ofbranches.uri,uriorcurieand their derived types behave exactly as before.The dumper also resolved the type without inheritance (
get_type), so a type derived fromurithat declares no datatype of its own was dumped as a plain literal with a warning. It now usesinduced_type, as the generators do, and that type is an IRI node.How was this tested?
tests/linkml/test_generators/test_anyuri_literal_types.pychecks one schema withuri, atypeof: uritype and atypeof: string, uri: xsd:anyURItype across all four components: context with and without the flag, anany_ofmixing a class with each, SHACL node kind and datatype, OWL property type with and without the flag, and the dumper's terms for an instance.test_jsonldcontextgen.py,test_shaclgen.py,test_shaclgen_naming.py,shacl/,test_owlgen.py,test_pythongen.py— 294 passed, 3 skipped, 3 xfailed.pytest tests/linkml_runtime— 1824 passed, 323 skipped, 2 xfailed, identical before and after the dumper change.ruff checkandruff format --check(0.11.13) clean.Areas of uncertainty
xsd:anyURItypes ingen-shacland the dumper. A schema that relied on such a type being an IRI should derive it fromuriinstead, which states that intent. I found none in the test suite.--xsd-anyuri-as-iriforgen-shacl. Not added:gen-shaclalready emits IRIs foruri/uriorcurie, so the remaining divergence is onlygen-owl's and the context's default, which the flag addresses.Checklist
AI Assistance
If you used AI tools while preparing this PR, you are still the author and responsible for understanding, verifying, and defending your submission. Please engage with reviewers personally rather than through your agent during feedback and revisions. See our AI Covenant for details.