admin-shell-io / aas-specs

Repository of the Asset Administration Shell Specification IDTA-01001 - Metamodel
https://admin-shell-io.github.io/aas-specs-antora/index/home/index.html
Creative Commons Attribution 4.0 International
47 stars 26 forks source link

enable the use of lang tags for langString #382

Open VladimirAlexiev opened 6 months ago

VladimirAlexiev commented 6 months ago

Similar to #284, both XML and RDF have a special means for attaching a lang tag; xml:lang and @lang.

In JSONLD, this is expressed as @value, @language and there are special ways to express a fixed lang tag, or organize JSON payload by lang (@collection: @language). Doing it with a separate field is non-idiomatic use.

The types aas:LangStringPreferredNameTypeIec61360, aas:LangStringTextType are parasitic and useless:

Instead of this:

  <https://admin-shell.io/aas/3/0/Referable/displayName> [
        rdf:type aas:LangStringNameType ;
        <https://admin-shell.io/aas/3/0/AbstractLangString/language> "de-CH"^^xs:string ;
        <https://admin-shell.io/aas/3/0/AbstractLangString/text> "something_1e73716d"^^xs:string ;
    ] ;
 <https://admin-shell.io/aas/3/0/DataSpecificationIec61360/preferredName> [
      rdf:type aas:LangStringPreferredNameTypeIec61360 ;
      <https://admin-shell.io/aas/3/0/AbstractLangString/language> "en-UK"^^xs:string ;
      <https://admin-shell.io/aas/3/0/AbstractLangString/text> "Something random in English 5b15c20d"^^xs:string ;
  ] ;

we want this:

  <https://admin-shell.io/aas/3/0/Referable/displayName>  "something_1e73716d"@de-CH;
  <https://admin-shell.io/aas/3/0/DataSpecificationIec61360/preferredName> "Something random in English 5b15c20d"@en-UK;
BirgitBoss commented 5 months ago

How would you express the length restrictions for these two types?

mhrimaz commented 5 months ago

aas:LangStringPreferredNameTypeIec61360, aas:LangStringTextType are not the source of issue in my opinion. The issue is that we introduce language attribute which is unnecessary. Of course, as I can already guess, this is because of schema generator. In addition, when we incorporate @VladimirAlexiev suggestion, we can also leverage built-in language restrictions of SHACL like sh:languageIn

so instead of this:

  <https://admin-shell.io/aas/3/0/Referable/displayName> [
        rdf:type aas:LangStringNameType ;
        <https://admin-shell.io/aas/3/0/AbstractLangString/language> "de-CH"^^xs:string ;
        <https://admin-shell.io/aas/3/0/AbstractLangString/text> "something_1e73716d"^^xs:string ;
    ] ;
 <https://admin-shell.io/aas/3/0/DataSpecificationIec61360/preferredName> [
      rdf:type aas:LangStringPreferredNameTypeIec61360 ;
      <https://admin-shell.io/aas/3/0/AbstractLangString/language> "en-UK"^^xs:string ;
      <https://admin-shell.io/aas/3/0/AbstractLangString/text> "Something random in English 5b15c20d"^^xs:string ;
  ] ;

We can have the following:

  <https://admin-shell.io/aas/3/0/Referable/displayName> [
        rdf:type aas:LangStringNameType ;
        <https://admin-shell.io/aas/3/0/AbstractLangString/text> "something_1e73716d"@de-CH;
    ] ;
 <https://admin-shell.io/aas/3/0/DataSpecificationIec61360/preferredName> [
      rdf:type aas:LangStringPreferredNameTypeIec61360 ;
      <https://admin-shell.io/aas/3/0/AbstractLangString/text> "Something random in English 5b15c20d"@en-UK ;
  ] ;

For sure, having different types like aas:LangStringPreferredNameTypeIec61360, aas:LangStringTextType are only because of length restriction. So same as how we do it now with SHACL, even if we remove them, we can for sure still express such length constraints. So what is suggested by @VladimirAlexiev actually goes one step further and makes it even simpler.

VladimirAlexiev commented 5 months ago

@BirgitBoss (cc @mhrimaz) We don't need a parasitic node that only holds a langString, because the class of that node doesn't say anything more than the incoming property.

How would you express the length restrictions for these two types?

Easily, we can specify that in the prop shape. You can search for these constructs in the Validation book https://book.validatingrdf.com/bookHtml011.html#sec142 :

aas-sh:SomeNodeShape # for each class that has these props:
  sh:property aas-sh:DisplayNameShape, aash-sh:PreferredNameShape.

aas-sh:DisplayNameShape a sh:PropertyShape;
  sh:path aas-ref:displayName; # or following the suggestion to reduce to just one namespace: aas:displayName
  sh:datatype rdf:langString;
  sh:maxLength 10.

aash-sh:PreferredNameShape a sh:PropertyShape;
  sh:path aas-ref:preferredName;
  sh:datatype rdf:langString;
  sh:maxLength 20.