[Specifications] Variable representation of individual template mappings (#244)

tpluscode has just created a new issue for https://github.com/HydraCG/Specifications:

== Variable representation of individual template mappings ==
## Describe the requirement

Right now it is only possible to set the variable representation of an entire `IriTemplate`. It would be nice to also allow selecting a specific variable representation of individual variables

## Example

Consider a paged collection with a category filter. The template could be `{?page,category}`. To have the `category` variable interpreted as an IRI, the entire template is best switched to `hydra:ExplicitRepresentation` but this unnecessarily blows up the `page` param in query. Identifier of page 5 would be `?page=%225%22%5E%5Ehttp%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23integer` instead of the simple `?page=5`

On the other hand, without explicit representation, the value `?cetegory=https%3A%2F%2Fexample.com%2Fcatergory%2Ffoo` would be interpreted as string unless additional processing would be applied by server and/or client.

## Proposed solutions

If we relaxed the domain of [`hydra:variableRepresentation`](http://www.hydra-cg.com/spec/latest/core/#hydra:variableRepresentation), it will become possible to individually choose the representation of each variable. The template itself would define the default, optionally overridden. Thus, the above could be achieved in two ways:

By making `category` explicit

```turtle
[
  a hydra:IriTemplate ;
  hydra:template "?page,category" ;
  hydra:mapping [
    # basic representation by default
    hydra:variable "page" ;
    hydra:property hydra:pageIndex ;
  ] , [
    hydra:variableRepresentation hydra:ExplicitRepresentation ;
    hydra:variable "category" ;
    hydra:property schema:category ;
  ] ;
] .
```

Or by making the entire template explicit and only `page` basic

```turtle
[
  a hydra:IriTemplate ;
  hydra:template "?page,category" ;
  hydra:variableRepresentation hydra:ExplicitRepresentation ;
  hydra:mapping [
    hydra:variableRepresentation hydra:BasicRepresentation ;
    hydra:variable "page" ;
    hydra:property hydra:pageIndex ;
  ] , [
    # explicit representation by default
    hydra:variable "category" ;
    hydra:property schema:category ;
  ] ;
] .
```


Please view or discuss this issue at https://github.com/HydraCG/Specifications/issues/244 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Sunday, 6 February 2022 12:22:25 UTC