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

Brutzman, Donald (Don) (CIV) brutzman at nps.edu
Mon Nov 18 06:21:36 PST 2019


Much work has been done on these multiple points.  Rather than insert into prior email, here are changes:

-----

1. X3DUOM includes tupleSize and isArray properties in each field type.

-----

2. Corresponding X3DJSAIL design now includes checks using this information.

-----

3. X3D Python has now also included this information in field types.  This allowed significant improvement in numeric MF types, now handling lists of tuples satisfactorily.  Also have upgraded to Python 3.8 and updated all examples.

TODO soon, will deploy X3D Python module update later today.

TODO later, is handling field/fieldValue declarations for Script and Proto, they still incorrectly default to string in all cases.

	https://www.web3d.org/x3d/content/examples/build.python.all.log.txt

-----

4.  This tupleSize and isArray information is also included in latest X3D Ontology.  All turtle examples have been updated to use numeric RDF lists instead of long strings.  Implemented and published.

	X3D Ontology for Semantic Web
	https://www.web3d.org/x3d/content/semantics/semantics.html

	https://www.web3d.org/x3d/content/examples/build.python.all.log.txt

	X3D Ontology for Semantic Web: Queries
	https://www.web3d.org/x3d/content/semantics/semantics.html#Queries

-----

5. For discussion in upcoming X3D Semantic Web telcon, of particular interest: querying a numeric list.  Good progress, more to do.

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

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

# Every X3D knowledge base can be subject to semantic queries.

# The following query retrieves the Background skyColor used in the scene.
# The result is the following list of RGB values: (0.7216 0.8 0.9922) (cf. Listing 3, line 6).

# Note special handling of RDF lists:
# Bob DuCharme's weblog, 21 April 2014, "RDF lists and SPARQL"
# http://www.snee.com/bobdc.blog/2014/04/rdf-lists-and-sparql.html

SELECT ?backgroundNode ?skyColorListValues

WHERE
{
     ?background rdf:type                          x3do:Background ;
                 x3do:skyColor/rdf:rest*/rdf:first ?skyColorListValues .

     BIND (strafter(xsd:string(?background),"#") AS ?backgroundNode)

     # TODO re-aggregate skyColor list values into list of tuples
}

###############################################
-----------------------------------------
| backgroundNode   | skyColorListValues |
=========================================
| "Background_2_2" | 0.7216             |
| "Background_2_2" | 0.8                |
| "Background_2_2" | 0.9922             |
----------------------------------------

6. Experimented and added some regex corrections to handle Apache Jena ARQ idiosyncracies in handling floats with trailing decimal point or negatives without leading zeroes.

https://www.web3d.org/specifications/X3dRegularExpressions.html#XmlPatterns

"🔖 Error-correction regexes are also possible using XPath replace(source,pattern,replacement) function. For repeatability the pattern being matched must be a strict regular expression rather than a literal."

Remove whitespace commas from appropriately typed numeric values
normalize-space(replace(., ',', ' '))

Omit trailing decimal point if followed by whitespace
normalize-space(replace(concat(replace(., ',', ' '),' '),'([.][ ])', ' '))

Insert 0 if negative fraction encountered, e.g. -.123 to -0.123
replace(normalize-space(replace(., ',', ' ')),'([-][.])', '-0.')

-----

7. Consistent support not found in X3D Schema tools for assert statement, will continue to track this possibility.

-----

Getting seriously strict and consistent with X3D data representations across multiple programming languages and file encodings.  Quality assurance (QA) is good.  Supporting X3Dv4 throughout.

Have fun with X3D!  8)


On 10/29/2019 8:37 AM, Brutzman, Donald (Don) (CIV) wrote:
> [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
> 


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