[semantics-public] X3DUOM improvements and X3D Ontology additions: further datatype information

Brutzman, Donald (Don) (CIV) brutzman at nps.edu
Tue Oct 29 08:37:47 PDT 2019


[Copying both public mailing lists, since this X3D Ontology improvement has a positive affect on all X3D.]

1. Something that might be improved in the X3D Ontology is datatype information for fields.

[1]	X3D Unified Object Model (X3DUOM)
	https://www.web3d.org/specifications/X3DUOM.html

[2]	X3D Ontology for Semantic Web
	https://www.web3d.org/x3d/content/semantics/

It is important to remember that we are not trying to duplicate schema validation of models, per se. Schemas are already good at that, and the XML form of a model (in .x3d form) has the strongest range of validation capabilities, i.e. strict typing, DOCTYPE, regex and X3D Schematron rules.  The X3D model itself is primary, and the turtle is an alternate form suitable for semantic query.

Nevertheless information about both X3D and XML datatypes is available in X3DUOM, and we want to make sure we offer the best possible advantage of that in .ttl representations, the X3D ontology, and for schema-compatible datatype-specific reasoning.

RDF/OWL supports the full range of XML datatypes, listed here:

[3]	XSD Datatypes
	This table lists the XSD datatypes present in the datatype maps defined for RDF, OWL, SPARQL, and RIF.
	https://www.w3.org/2011/rdf-wg/wiki/XSD_Datatypes

[4]	OWL 2 Web Ontology Language
	Structural Specification and Functional-Style Syntax (Second Edition)
	W3C Recommendation 11 December 2012
	4 Datatype Maps
	https://www.w3.org/TR/2012/REC-owl2-syntax-20121211/#Datatype_Maps

[5]	RDF 1.1 Semantics
	W3C Recommendation 25 February 2014
	7. Literals and datatypes
	https://www.w3.org/TR/rdf11-mt/#literals-and-datatypes

-----

a. X3D Ontology currently has information like this:

:colorIndex a owl:DatatypeProperty ;
   rdfs:domain :IndexedLineSet ;
   rdfs:range :MFInt32 .
:colorPerVertex a owl:DatatypeProperty ;
   rdfs:domain :IndexedLineSet ;
   rdfs:range :SFBool .

:SFFloat rdf:type rdfs:Datatype ;
   rdfs:subClassOf :X3DField ;
   dc:description "SFFloat is a single-precision floating-point type" .

:MFInt32 rdf:type rdfs:Datatype ;
   rdfs:subClassOf :X3DField ;
   dc:description "An MFInt32 field defines an array of 32-bit signed integers" .

-----

b. Example conversions (such as HelloWorld.ttl) have information like this:

:ViewUpClose a owl:NamedIndividual, x3do:Viewpoint ;
   x3do:hasParent :Group_2_2 ;
   x3do:centerOfRotation "0 -1 0" ;
   x3do:description "Hello world!" ;
   x3do:position "0 -1 7" .

:Transform_2_2_2 a owl:NamedIndividual, x3do:Transform ;
   x3do:hasParent :Group_2_2 ;
   x3do:hasChildren :Shape_2_2_2_1 ;
   x3do:rotation "0 1 0 3" .

-----

c. X3DUOM has information like this:

       <FieldType type="SFInt32"
                  tupleSize="1"
                  defaultValue="0"
                  regex="(\s)*[+-]?(0|[1-9][0-9]*)([Ee][+-]?[0-9]+)?(\s)*">
          <InterfaceDefinition specificationUrl="https://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/fieldsDef.html#SFInt32AndMFInt32"
                               appinfo="An SFInt32 field specifies one 32-bit signed integer.">
             <Inheritance baseType="xs:integer"/>
          </InterfaceDefinition>
       </FieldType>

       <FieldType type="MFFloat"
                  tupleSize="1"
                  defaultValue=""
                  regex="(\s)*(([+-]?((0|[1-9][0-9]*)(\.[0-9]*)?|\.[0-9]+)([Ee][+-]?[0-9]+)?)\s*,?\s*)*">
          <InterfaceDefinition specificationUrl="https://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/fieldsDef.html#SFFloatAndMFFloat"
                               appinfo="MFFloat is an array of SFFloat values, meaning a single-precision floating-point array type. Array values are optionally separated by commas.">
             <Inheritance baseType="xs:string"/>
          </InterfaceDefinition>
       </FieldType>

Note that sometimes the inheritance is sometimes xs:string because an X3D floating-point array might have commas as whitespace, making the regex more strictly correct.  Nevertheless the data itself will be of datatype xsd:float.

==========================

2. Suggested improvements:

a. *XML Schema and X3DUOM*.  modify annotations in XML Schema and thus X3DUOM to list xsd base types, since regexes are always/implicitly string based.  This gives other tools the option to use whatever form is preferred: native X3D types, native XML Schema (XSD) types, or regular expression (regex) checking of string types.  Hmmm, looks like xs:integer above already matches that form.  So example above

  <Inheritance baseType="xs:string"/>

becomes

  <Inheritance baseType="xs:float"/>

or perhaps for MFVec3f things like

  <Inheritance baseType="xs:float" arrayType="true"/>

or even

  <Inheritance baseType="xs:float" arrayType="true" tupleSize/>

Note that XSD has simple array representations, not arrays of tuples.  So XSD arrays might not be an exact match of triples, e.g. a ColorInterpolator array might erroneously have 7 values yet pass such validation.  (We recommended arrays of tuples during specification design but that feature did not "make the cut" in the final specification.)

Of note is that X3D regexes do enforce tuple size.

[6]	X3D Regular Expressions (regexes)
	https://www.web3d.org/specifications/X3dRegularExpressions.html

-----

b. *XML Schema Assertions*.  Looks like there is a useful feature in XML Schema that we haven't included, namely assertions.  Reference and example follow.

[6]	W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures
	W3C Recommendation 5 April 2012
	3.13 Assertions
	https://www.w3.org/TR/xmlschema11-1/#cAssertions

> ================
> Example
> 
> <xs:assert test="@min le @max"/>
> 
> The XML representation for assertions.
> The <assert> element requires that the value of the min attribute be less than or equal to that of the max attribute, and fails if that is not the case.
> ================

Hmmm, maybe we can codify tupleSize somehow as xs:assert statements in the X3D XML schema.  Further scrutiny warranted.

-----

c. *X3D Ontology*.  We can add properties to ontology describing relationship to XML datatypes for each X3D type.  For example

:SFFloat rdf:type rdfs:Datatype ;
   rdfs:subClassOf :X3DField ;
   dc:description "SFFloat is a single-precision floating-point type" .

might become

:SFFloat rdf:type rdfs:Datatype ;
   rdfs:subClassOf :X3DField ;
   rdf:datatype    xsd:float ;
   dc:description "SFFloat is a single-precision floating-point type" .

-----

d. *No whitespace commas*.  Intermediate commas in arrays, and other whitespace characters from source models need to be normalized as a single space character for compatibility with XML schema (XSD) types.  This improves file size, data interoperability and query complexity without loss of information.

-----

e. *Noting XML types*. Instead of always using strings, use alternate representations of values in .ttl that better reveals type.  Examples:

# http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter02GeometryPrimitives/Cone.ttl

:Cone_2_5_1 a owl:NamedIndividual, x3do:Cone ;
   x3do:hasParent :Shape_2_5 ;
   x3do:height "1" .

becomes
:Cone_2_5_1 a owl:NamedIndividual, x3do:Cone ;
   x3do:hasParent :Shape_2_5 ;
   x3do:height 1 .

:ViewUpClose a owl:NamedIndividual, x3do:Viewpoint ;
   x3do:hasParent :Group_2_2 ;
   x3do:centerOfRotation "0 -1 0" ;
   x3do:description "Hello world!" ;
   x3do:position "0 -1 7" .

might become something like

:ViewUpClose a owl:NamedIndividual, x3do:Viewpoint ;
   x3do:hasParent :Group_2_2 ;
   x3do:centerOfRotation [0 -1 0] ; # TODO check syntax, might only be possible for singleton values
   x3do:description "Hello world!" ;
   x3do:position "0 -1 7"^^xsd:float . # TODO seems pretty verbose and may be unnecessary if X3D Ontology relationships are good enough.

-----

f. *Confirmation*. As ever, demonstrating proof of pudding: write queries that provide repeatable examples of how quantitative comparisons can work correctly.

	Wiktionary: "the proof of the pudding is in the eating"
	https://en.wiktionary.org/wiki/the_proof_of_the_pudding_is_in_the_eating

What else? Additional ideas and feedback are welcome, thanks for all scrutiny.

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 semantics-public mailing list