Re: Client-side Preprocessing and the Semantic Web

Semantic Web Interest Group,


For those interested in “client-side preprocessing” and “semantic templates”, I recently started migrating these concepts from markup to Turtle/TriG. Please feel free to also join the discussion and brainstorming session here: https://github.com/w3c-cg/planning/discussions/25 .

Here is a sketch which intends to show that content, e.g., PHP, can be preprocessed into other content, e.g., TriG, client-side, with arguments for the template parameters passed to the preprocessing environment:


@prefix aps: <http://www.w3.org/community/planning/> .
@prefix dc:  <http://purl.org/dc/elements/1.1/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

<http://example.org/#template123>
        rdf:type                aps:Template ;
        rdf:value               [ rdf:type   aps:Data ;
                                  dc:format  "application/trig" ;
                                  dc:source  [ rdf:type   aps:Data ;
                                               rdf:value  "... php ..." ;
                                               dc:format  "text/php"
                                             ]
                                ] ;
        aps:templateParameters  [ rdf:type      aps:ParameterList ;
                                  rdf:value     ( [ rdf:type  aps:Parameter ;
                                                    aps:name  "T1"
                                                  ]
                                                  [ rdf:type  aps:Parameter ;
                                                    aps:name  "T2"
                                                  ]
                                                ) ;
                                  aps:requires  [ rdf:type   aps:Data ;
                                                  rdf:value  "function guard(world, t1, t2) { ... javascript ... }" ;
                                                  dc:format  "text/javascript"
                                                ]
                                ] .

Thank you. Questions, comments, feedback, and ideas welcomed.


Best regards,

Adam Sobieski


P.S.: A related idea is that there could be an "aps:instanceURI" property available for some semantic templates, for URI's or URI pattern strings onto which URL-escaped query string parameters and values could be added. For example, an instance URI of "http://example.org/#instance123" could be transformed into: "http://example.org/?T1=arg1&T2=arg2#instance123" where "T1" and "T2" were template parameters and "arg1" and "arg2" were serialized arguments, e.g., URI's or identifiers. In this way, individual instances produced from semantic templates could each have automatically-generated identifiers.


________________________________
From: Adam Sobieski <adamsobieski@hotmail.com>
Sent: Thursday, December 1, 2022 10:30 AM
To: semantic-web@w3.org <semantic-web@w3.org>
Subject: Client-side Preprocessing and the Semantic Web


Semantic Web Interest Group,



Hello. I am pleased to share some ideas from the new Automated Planning and Scheduling Community Group<https://www.w3.org/community/planning/> pertaining to client-side preprocessing. These techniques can enable templating, generics, parametric polymorphism, and macros with every Semantic Web format.


These ideas are presented at and can also be discussed at the following locations:

https://github.com/WICG/proposals/issues/82

https://github.com/w3c-cg/planning/discussions/21



These techniques allow preprocessors, e.g., GPP or PHP, to process and produce content, e.g., N3, client-side and for this client-side preprocessing to be simply declared using markup.

<script preprocess="text/php" type="application/ld+json" src="..." />

<script preprocess="text/php" type="application/ld+json">PHP content which, when processed, results in JSON-LD</script>


Some preprocessors, e.g., PHP, can be provided with environment variables. This capability can allow arguments, e.g., templating arguments, to be passed to preprocessing contexts. Knowledgebases can also be provided to preprocessing contexts so that knowledge about arguments can be used during preprocessing. The following is a rough-draft sketch of a generic type definition which uses client-side preprocessing to vary N3 contents:


<types>
  <type name="widget" uri="...">
    <parameters>
      <parameter name="T" uri="...">
        <!-- describe type parameter here -->
      </parameter>
    </parameters>
    <metadata preprocess="text/php" type="text/n3">
      <!-- preprocessor receives the type argument for parameter T and a knowledgebase -->
    </metadata>
    <definition preprocess="text/php" type="text/n3">
      <!-- preprocessor receives the type argument for parameter T and a knowledgebase -->
    </definition>
  </type>
</types>


Thank you.




Best regards,

Adam Sobieski

Received on Tuesday, 6 December 2022 10:25:02 UTC