[x3d-public] how to best represent X3D enumeration values in X3D Ontology? defining literals with double underscore characters

Don Brutzman brutzman at nps.edu
Wed Mar 24 17:30:49 PDT 2021


Jakub, thanks for abbreviated weekly call Tuesday.

1. First *thanks!* for observing that the period character . is not allowed as a naming character.  I experimented using single underscore "_" instead, but that seemed insufficiently unique.  Have instead tried a double underscore "__" which actually looks pretty good.

Example ontology excerpts:
--------------------------

:geoMetadataKeyValues rdf:type rdfs:Datatype ;
   rdfs:label "geoMetadataKeyValues" ;
   dcterms:description "The keyword values for the summary field";
   dcterms:reference "https://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/geodata.html#t-keywordsandvalues" ;
   rdfs:domain xsd:NMTOKEN ;
   rdfs:range [ owl:oneOf ( 'title' 'description' 'coordinateSystem' 'horizontalDatum' 'verticalDatum' 'ellipsoid' 'extent' 'resolution' 'originator' 'copyright' 'date' 'metadataFormat' 'dataUrl' 'dataFormat' ) ] .

:geoMetadataKey__title rdfs:label 'title'^^xsd:string ;
   dcterms:description "A name to succinctly identify the dataset to user. For example, San Francisco, California." .
:geoMetadataKey__description rdfs:label 'description'^^xsd:string ;
   dcterms:description "A brief textual description or summary of the content of the dataset. For example, LANDSAT 7 satellite imagery taken over northern Scotland." .
:geoMetadataKey__coordinateSystem rdfs:label 'coordinateSystem'^^xsd:string ;
   dcterms:description "The spatial reference frame used to represent the data (e.g., GD, UTM, or LCC). The list of valid codes that can be used in this field are defined in ISO/IEC 18026. In the case of UTM, the zone number should also be specified in the format UTM Zx, where the zone number is in the range [1,60]. For example, UTM Z11." .
:geoMetadataKey__horizontalDatum rdfs:label 'horizontalDatum'^^xsd:string ;
   dcterms:description "The name of the geodetic datum. The list of valid codes that can be used in this field are defined in ISO/IEC 18026. For example, W84." .
:geoMetadataKey__verticalDatum rdfs:label 'verticalDatum'^^xsd:string ;
   dcterms:description "The name of the vertical datum (geoid). The list of valid codes that can be used in this field are defined in ISO/IEC 18026. For example, W84." .
:geoMetadataKey__ellipsoid rdfs:label 'ellipsoid'^^xsd:string ;
   dcterms:description "The name of the geodetic ellipsoid. The list of valid codes that can be used in this field are defined in ISO/IEC 18026. For example, WE." .
:geoMetadataKey__extent rdfs:label 'extent'^^xsd:string ;
   dcterms:description "The bounding coordinates for the dataset given in spatial reference frame specified by the coordinateSystem keyword. These are provided in the order eastmost, southmost, westmost, northmost. An example for GD is: -180.0 -90.0 180.0 90.0." .
:geoMetadataKey__resolution rdfs:label 'resolution'^^xsd:string ;
   dcterms:description "SFFloat resolution, or ground sample distance, given in units of length base units. For example, 30." .
:geoMetadataKey__originator rdfs:label 'originator'^^xsd:string ;
   dcterms:description "A string defining the originator of the data, for example the author, agency, organization, publisher, etc. For example, John Doe, Any Corporation, Some Town, Some Country" .
:geoMetadataKey__copyright rdfs:label 'copyright'^^xsd:string ;
   dcterms:description "Any appropriate copyright declaration that pertains to the data. For example, (c) Copyright 2000, Any Corporation. All rights reserved. Freely distributable." .
:geoMetadataKey__date rdfs:label 'date'^^xsd:string ;
   dcterms:description "A single date/time, or a date/time range, defining the valid time period to which the data pertains. Dates are specified in the format YYYY MM DD [HH:MM]. Years in the current time period should be specified using four digits (EXAMPLE 1999 or 2001). Years can have other than four digits and can be negative. A date range is specified by supplying two values separated by a - (hyphen) character. An optional time can be supplied should this level of accuracy be required. Times are to be specified in 24-hour format with respect to GMT. For example, 1999 01 01 00:00 - 1999 12 31 23:59." .
:geoMetadataKey__metadataFormat rdfs:label 'metadataFormat'^^xsd:string ;
   dcterms:description "A string that specifies the format of the external metadata description specified by the url field of the GeoMetadata node. For example, FGDC, ISO TC211, CEN TC287, or OGC." .
:geoMetadataKey__dataUrl rdfs:label 'dataUrl'^^xsd:string ;
   dcterms:description "A hypertext link to the source data used to create the X3D node(s) to which this metadata pertains. Multiple dataUrl keyword/value pairs can be specified in order to provide alternative locations for the same source data. For example, https://www.foo.bar/data/sf1." .
:geoMetadataKey__dataFormat rdfs:label 'dataFormat'^^xsd:string ;
   dcterms:description "A free-text string that describes the format of the source data used to create the X3D node(s) to which this metadata pertains. This refers to the source data specified by the dataUrl keyword (if present). For example, USGS 5.5-min DEM." .

--------------------------

:hanimHumanoidInfoKeyValues rdf:type rdfs:Datatype ;
   rdfs:label "hanimHumanoidInfoKeyValues" ;
   dcterms:description "Keyword names for keyword=value metadata pairs describing a given HAnimHumanoid. Additional keyword=value pairs may be included as needed for specific applications.";
   dcterms:reference "https://www.web3d.org/documents/specifications/19774/V2.0/Architecture/ObjectInterfaces.html#Humanoid" ;
   rdfs:domain xsd:NMTOKEN ;
   rdfs:range [ owl:oneOf ( 'authorName' 'authorEmail' 'copyright' 'creationDate' 'usageRestrictions' 'humanoidVersion' 'age' 'gender' 'height' 'weight' ) ] .

:hanimHumanoidInfoKey__authorName rdfs:label 'authorName'^^xsd:string ;
   dcterms:description "Name of Humanoid author." .
:hanimHumanoidInfoKey__authorEmail rdfs:label 'authorEmail'^^xsd:string ;
   dcterms:description "Email address of Humanoid author." .
:hanimHumanoidInfoKey__copyright rdfs:label 'copyright'^^xsd:string ;
   dcterms:description "Copyright information for this Humanoid model (if any)." .
:hanimHumanoidInfoKey__creationDate rdfs:label 'creationDate'^^xsd:string ;
   dcterms:description "Creation data for this for this Humanoid model." .
:hanimHumanoidInfoKey__usageRestrictions rdfs:label 'usageRestrictions'^^xsd:string ;
   dcterms:description "Usage restrictions for this Humanoid model (if any)." .
:hanimHumanoidInfoKey__humanoidVersion rdfs:label 'humanoidVersion'^^xsd:string ;
   dcterms:description "The humanoidVersion term refers to the version of the humanoid being used, in order to track revisions to the data. It is not the same as the version field of the Humanoid object, which refers to the version of the HAnim specification that was used when building the humanoid." .
:hanimHumanoidInfoKey__age rdfs:label 'age'^^xsd:string ;
   dcterms:description "Description of Humanoid age (not necessarily numeric)." .
:hanimHumanoidInfoKey__gender rdfs:label 'gender'^^xsd:string ;
   dcterms:description "The gender term typically has a value of female, male or neuter." .
:hanimHumanoidInfoKey__height rdfs:label 'height'^^xsd:string ;
   dcterms:description "SFFloat Humanoid height in base units (typically meters)." .
:hanimHumanoidInfoKey__weight rdfs:label 'weight'^^xsd:string ;
   dcterms:description "SFFloat Humanoid weight in base units (typically kilograms)." .

--------------------------

2. Updated query excerpt:

* https://www.web3d.org/x3d/content/semantics/queries/X3dOntologyQuery_05.rq.txt

--------------------------

Perform X3D Ontology metaquery X3dOntologyQuery_05.rq to produce output file X3dOntologyQuery_05.rq.txt:

PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:    <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl:     <http://www.w3.org/2002/07/owl#>
PREFIX xsd:     <http://www.w3.org/2001/XMLSchema#>
PREFIX x3d:     <https://www.web3d.org/specifications/x3d-4.0.xsd#>
PREFIX x3do:    <https://www.web3d.org/specifications/X3dOntology4.0#>
PREFIX dcterms: <http://purl.org/dc/terms/>

# X3dOntologyQuery_05.rq	Metaquery to list all X3D enumeration literals (constants).

# SPARQL 1.1 has arbitrary depth traversal
# https://stackoverflow.com/questions/1458674/retrieving-all-the-ancestors-of-a-rdfclass

###############################################

SELECT ?enumeration__literal ?enumerationValue ### also available: ?description ?reference
WHERE
{
    ?iriEnumerationLiteral rdfs:label ?enumerationValue .

    OPTIONAL
    {
       ?iriEnumerationLiteral dcterms:description ?description .
    }
    OPTIONAL
    {
       ?iriEnumerationLiteral dcterms:reference   ?reference   .
    }

    BIND (strafter(xsd:string(?iriEnumerationLiteral),"#") AS ?enumeration__literal)

    # appropriate labels of interest here includes underscore within
    # pattern enumerationType_SomeName, e.g. :fontStyle_PLAIN
    FILTER ( CONTAINS(str(?enumeration__literal),"__") )
}
ORDER by ASC(?enumeration__literal) # alphabetize

###############################################
----------------------------------------------------------------------------------------------------------
| enumeration__literal                                          | enumerationValue                       |
==========================================================================================================
| "accessType__initializeOnly"                                  | "initializeOnly"                       |
| "accessType__inputOnly"                                       | "inputOnly"                            |
| "accessType__inputOutput"                                     | "inputOutput"                          |
| "accessType__outputOnly"                                      | "outputOnly"                           |
| "alphaMode__AUTO"                                             | "AUTO"                                 |
| "alphaMode__BLEND"                                            | "BLEND"                                |
| "alphaMode__MASK"                                             | "MASK"                                 |
| "alphaMode__OPAQUE"                                           | "OPAQUE"                               |
| "appliedParameters__BOUNCE"                                   | "BOUNCE"                               |
| "appliedParameters__CONSTANT_FORCE"                           | "CONSTANT_FORCE"                       |
| "appliedParameters__ERROR_REDUCTION"                          | "ERROR_REDUCTION"                      |
| "appliedParameters__FRICTION_COEFFICIENT2"                    | "FRICTION_COEFFICIENT-2"               |
| "appliedParameters__SLIP1"                                    | "SLIP-1"                               |
| "appliedParameters__SLIP2"                                    | "SLIP-2"                               |
| "appliedParameters__SPEED1"                                   | "SPEED-1"                              |
| "appliedParameters__SPEED2"                                   | "SPEED-2"                              |
| "appliedParameters__USER_FRICTION"                            | "USER_FRICTION"                        |
| "biquadTypeFilter__allpass"                                   | "allpass"                              |
| "biquadTypeFilter__bandpass"                                  | "bandpass"                             |
| "biquadTypeFilter__highpass"                                  | "highpass"                             |
| "biquadTypeFilter__highshelf"                                 | "highshelf"                            |
| "biquadTypeFilter__lowpass"                                   | "lowpass"                              |
| "biquadTypeFilter__lowshelf"                                  | "lowshelf"                             |
| "biquadTypeFilter__notch"                                     | "notch"                                |
| "biquadTypeFilter__peaking"                                   | "peaking"                              |
| "channelCountMode__clampedmax"                                | "clamped-max"                          |
| "channelCountMode__explicit"                                  | "explicit"                             |
| "channelCountMode__max"                                       | "max"                                  |
| "channelInterpretation__discrete"                             | "discrete"                             |
| "channelInterpretation__speakers"                             | "speakers"                             |
| "closureType__CHORD"                                          | "CHORD"                                |
| "closureType__PIE"                                            | "PIE"                                  |
| "componentName__CADGeometry"                                  | "CADGeometry"                          |
| "componentName__Core"                                         | "Core"                                 |
| "componentName__CubeMapTexturing"                             | "CubeMapTexturing"                     |
| "componentName__DIS"                                          | "DIS"                                  |
| "componentName__EnvironmentalEffects"                         | "EnvironmentalEffects"                 |
| "componentName__EnvironmentalSensor"                          | "EnvironmentalSensor"                  |
| "componentName__EventUtilities"                               | "EventUtilities"                       |
| "componentName__Followers"                                    | "Followers"                            |
| "componentName__Geometry2D"                                   | "Geometry2D"                           |
| "componentName__Geometry3D"                                   | "Geometry3D"                           |
| "componentName__Geospatial"                                   | "Geospatial"                           |
| "componentName__Grouping"                                     | "Grouping"                             |
| "componentName__HAnim"                                        | "H-Anim"                               |
| "componentName__HAnim"                                        | "HAnim"                                |

[... etc. ...]

Have checked in all changes and deployed.

---

3. Still not able to find those labels in Protege.  Not a problem per se, but seems like a reasonable feature for them to add.  Shall we submit an issue report to them?

Next effort: querying for that metadata in X3D models.

Hoping to skip meeting next week, starting a new quarter...  will try to call in briefly if you want.

Onwards we go, thanks again Jakub.


On 3/20/2021 11:03 PM, Don Brutzman wrote:
> Changing course:  I don't think we should be defining classes for our enumeration string constants. Collections of those values are already defined, as in:
> 
> :hanimHumanoidInfoKeyValues rdf:type rdfs:Datatype ;
>     rdfs:label "hanimHumanoidInfoKeyValues" ;
>     dc:description "Keyword names for keyword=value metadata pairs describing a given HAnimHumanoid. Additional keyword=value pairs may be included as needed for specific applications." ;
>     rdfs:domain xsd:NMTOKEN ;
>     rdfs:range [ owl:oneOf ( 'authorName' 'authorEmail' 'copyright' 'creationDate' 'usageRestrictions' 'humanoidVersion' 'age' 'gender' 'height' 'weight' ) ] .
> 
> # authorName "Name of Humanoid author."
> # [... etc, ...]
> 
> The correct term in RDF for this kind of construct is "literal" so that is what we seek.
> 
> [1]    RDF 1.1 Turtle, Terse RDF Triple Language
>         W3C Recommendation 25 February 2014
>         https://www.w3.org/TR/turtle
> 
> [2]    RDF 1.1 Turtle, 2.5 RDF Literals
>         https://www.w3.org/TR/turtle/#literals
> 
> [3]    RDF 1.1 Turtle, 2.5.1 Quoted Literals
>         https://www.w3.org/TR/turtle/#turtle-literals
> 
>> Example 11
>>
>> @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
>> @prefix show: <http://example.org/vocab/show/> .
>> @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
>>
>> show:218 rdfs:label "That Seventies Show"^^xsd:string .            # literal with XML Schema string datatype
> 
> Once again, the semantic web jargon doesn't align cleanly to object-oriented jargon... lesson learned.
> 
> So maybe ours should be something like
> 
> :hanimHumanoidInfo.authorName rdfs:label "authorName"^^xsd:string ;
>       dc:description "Name of Humanoid author" .
> 
> Seems simple enough so I went ahead and applied this pattern.  Had to handle things like blanks quotes and minus signs in enumeration literals when creating corresponding names.  Looks like it works, all of our build tests using JENA ARQ still pass OK.
> 
> Curiously Protege also validates the updated ontology, but am not finding a way to inspect these constructs directly in the interface...
> 
> If you can't find them either, perhaps we should we post a bug report to Protege?
> 
> I added a SPARQL query to test that everything is working OK.
> 
> * https://www.web3d.org/x3d/content/semantics/semantics.html#X3dOntologyQueries
> * https://www.web3d.org/x3d/content/semantics/queries/X3dOntologyQuery_05.rq
> * https://www.web3d.org/x3d/content/semantics/queries/X3dOntologyQuery_05.rq.txt
> 
> Next step to follow: SPARQL queries for GeoMetadata.summary and HAnimHumanoid.info metadata.
> 
> Step by step.
> [...]

all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman



More information about the x3d-public mailing list