Skip to content

sigil: change prefix char in context #51

@VladimirAlexiev

Description

@VladimirAlexiev

As an information architect and developer.
I want to write YAML-LD keywords using identifier chars accepted in YAML and in my programming language.
So that I can access them using dot notation, rather than using "string index" bracketed notation.

Example: if the prefix char is _ :

  • I can have more readable YAML without quoting keys (see Example with context below)
  • I can write this in JavaScript:
label._none // with Language Indexing, if the label has no lang tag
label._value // with langString

instead of

label["@none"]
label["@value"]

(see JSON-LD Language Indexing)


JSON-LD takes a per-keyword approach, i.e. you can define keyword aliases, eg

"@context":{
  "type":"@type",
  "id":"@id",
  "lang":"@language",
  "none":"@none"
}

A more uniform way in YAML-LD could be to specify the prefix char ($ or _ or even empty) with an option.

Example with context (TODO make more)

  "@context":
    "@sigil": $
    $base: http://example.org/resource/
    $vocab: http://example.org/ontology/
  $graph:
    $id: bart
    spouse: marge

TODO: is there any way to avoid the use of @ in the first 2 lines?

@ioggstream and @anatoly-scherbakov I tried \ escaping but it doesn't work at https://onlineyamltools.com/convert-yaml-to-json, maybe that convertor is non-conforming?

\@context:
  \@sigil: $
  $base: http://example.org/resource/
  $vocab: http://example.org/ontology/
$graph:
  $id: bart
  spouse: marge

JSON Schema includes some $ keywords:
"$schema, $vocabulary, $defs, $ref, $id, $anchor, $comment, $dynamicRef, $dynamicAnchor`

  • on one hand, if we come up with some YAML beast to combine YAML-LD Context and YAML Schema (see Polyglot Modeling #19, I think @OR13 uses such things) it would be nice to use the same sigil for keywords
  • on the other hand, we should look out for conflicts
    • @id is a conflict with $id
    • @vocab is a near-conflict with $vocabulary (i.e. could be confusing)
  • But maybe there is no problem if these keywords are localized to the Context vs Schema parts?
    • After all, @id is already "overloaded" in JSON-LD:
"@container": "@id" # Node Identifier Indexing
"@id": "bart"             # Node identifier
"@id": {"@id": "bart", "age": 42}  # triple, for which RDF-star annotations will follow

Related issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    UCRIssue on Use Case/Recommendation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions