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
50 stars 26 forks source link

XSD data types instead of xs:string for value type #284

Open mhrimaz opened 1 year ago

mhrimaz commented 1 year ago

I was wondering why, for value, the type is always xs:string and we use 'valueType' with DataTypeDefXsd/* as value?

If everything is a string, then how do I query over property values? Either I should manually convert the types or infer the types automatically. But in the provided ontology, DataTypeDefXsd does not contain any linking to the actual XSD type.

image

Example Double property serializaiotion

@prefix aas: <https://admin-shell.io/aas/3/0/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xs: <http://www.w3.org/2001/XMLSchema#> .

<something_48c66017> rdf:type aas:Submodel ;
    <https://admin-shell.io/aas/3/0/Identifiable/id> "something_48c66017"^^xs:string ;
    <https://admin-shell.io/aas/3/0/Submodel/submodelElements> [
        rdf:type aas:Property ;
        <https://admin-shell.io/aas/3/0/Referable/idShort> "something3fdd3eb4"^^xs:string ;
        <https://admin-shell.io/aas/3/0/Property/valueType> <https://admin-shell.io/aas/3/0/DataTypeDefXsd/Double> ;
        <https://admin-shell.io/aas/3/0/Property/value> "1234.01234"^^xs:string ;
    ] ;
.

One alternative approach: instead of <https://admin-shell.io/aas/3/0/Property/value> "1234.01234"^^xs:string ; we use <https://admin-shell.io/aas/3/0/Property/value> "1234.01234"^^xs:double; and remove <https://admin-shell.io/aas/3/0/Property/valueType> <https://admin-shell.io/aas/3/0/DataTypeDefXsd/Double> ; because it is redundant.

@prefix aas: <https://admin-shell.io/aas/3/0/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xs: <http://www.w3.org/2001/XMLSchema#> .

<something_48c66017> rdf:type aas:Submodel ;
    <https://admin-shell.io/aas/3/0/Identifiable/id> "something_48c66017"^^xs:string ;
    <https://admin-shell.io/aas/3/0/Submodel/submodelElements> [
        rdf:type aas:Property ;
        <https://admin-shell.io/aas/3/0/Referable/idShort> "something3fdd3eb4"^^xs:string ;
        <https://admin-shell.io/aas/3/0/Property/value> "1234.01234"^^xs:double;
    ] ;
.
mhrimaz commented 1 year ago

As discussed in IDTA Open Hours, the reason was because of more flexibility, avoiding information loss in round trip conversions, and stay consistent with XML/JSON mapping.

mhrimaz commented 1 year ago

@sebbader Regarding the datatypes, as it was mentioned, the string type chosen for all types. However, in DataSpecificationIec61360 the level type has boolean datatype: https://github.com/admin-shell-io/aas-specs/blob/bb6747a17ca51d3a08bcf03b2fc927671ab3433b/schemas/rdf/examples/generated/DataSpecificationIec61360/maximal.ttl#L57-L63 Is this an inconsistency or there is a reason for it?

mhrimaz commented 11 months ago

Furthermore in Blob we are also using xsd:base64Binary https://github.com/admin-shell-io/aas-specs/blob/13b904f5b546aade0459b40e3b30953e6af50e0a/schemas/rdf/examples/generated/Blob/maximal.ttl#L76

mhrimaz commented 11 months ago

@kenwenzel Do you have any idea regarding the usage of datatypes and also the inconsistencies?

mristin commented 9 months ago

@mhrimaz just a remark related to these changes: please make sure that you patch aas-core-codegen, not the schemas directly.

VladimirAlexiev commented 8 months ago

I also agree that this is not idiomatic RDF and has many problems.

more flexibility

More flexibility at the loss of defined functionality is no win at all.

Why no XML attributes?

I find the arguments here weak.

avoiding information loss in round trip conversions, stay consistent with XML/JSON mapping

There is no information loss!

in DataSpecificationIec61360 the level type has boolean datatype in Blob we are also using xsd:base64Binary

The reason is that these props are predefined (fixed) in the spec. But such rational use is not permitted for props to be defined in a particular AAS application ;-)

VladimirAlexiev commented 8 months ago

@mristin @mhrimaz @sebbader @kenwenzel @wiresio

aas:DataTypeDefXsd defines its own URLs so it disregards the XSD Datatypes standard, which was defined:

I think it is a bad practice to disregard age-tested standards, especially those that are the basis of typed values in both XML and RDF.

Eg If we take this as example: https://github.com/admin-shell-io/aas-specs/blob/2ab08f92bdd1d44edc1cfee52552fe5429d2178e/schemas/rdf/examples/generated/Property/OverValueExamples/Any_URI/relative_path_without_scheme.ttl#L9-L14

it should be changed to the following (skipping ^^xs:string, which is superfluous)

    <https://admin-shell.io/aas/3/0/Submodel/submodelElements> [
        rdf:type aas:Property ;
        <https://admin-shell.io/aas/3/0/Referable/idShort> "something3fdd3eb4";
        <https://admin-shell.io/aas/3/0/Property/value> "path/to/somewhere"^^xs:anyURI;
    ] ;

Can you point me to some JSON examples? Then we can figure out how to enrich the context to convert the JSON to this desired RDF representation.

BirgitBoss commented 7 months ago

..