aas-specs icon indicating copy to clipboard operation
aas-specs copied to clipboard

enable the use of lang tags for langString

Open VladimirAlexiev opened this issue 11 months ago • 3 comments

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:

  • there is already rdf:langString,
  • the distinction between the two types is already expressed by the incoming property

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;

VladimirAlexiev avatar Mar 11 '24 06:03 VladimirAlexiev

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

BirgitBoss avatar Apr 20 '24 20:04 BirgitBoss

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.

mhrimaz avatar Apr 21 '24 12:04 mhrimaz

@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.

VladimirAlexiev avatar Apr 23 '24 10:04 VladimirAlexiev