[x3d-public] X3D.py checks for DEF, USE

Brutzman, Donald (Don) (CIV) brutzman at nps.edu
Sat Feb 24 15:22:53 PST 2024


John: here are the references which answer your python-related questions.

 

a.	The data type xs:NMTOKEN plays an important role in DEF, USE, and some names in X3D XML.  Derivative data types xs:ID and xs:IDREF  prevents inadvertent validation of a large variety of illegal values.  This significantly improves quality assurance (QA) for X3D models.

 

*	X3D Tooltips, XML data types
*	https://www.web3d.org/x3d/content/X3dTooltips.html#XML
*	ID <https://www.w3.org/TR/REC-xml/#sec-attribute-types>  is a NMTOKEN that is unique within the scene, corresponding to the DEF attribute in X3D.
*	IDREF <https://www.w3.org/TR/REC-xml/#sec-attribute-types>  is a NMTOKEN reference to one of these unique scene IDs, corresponding to the USE attribute in X3D.
*	[… snip …]
*	NMTOKEN <https://www.w3.org/TR/REC-xml/#sec-common-syn>  is an XML term for Name Token <https://www.w3.org/TR/REC-xml/#sec-common-syn> . NMTOKEN is a special kind of CDATA <https://www.web3d.org/x3d/content/X3dTooltips.html#CDATA>  string that must match naming requirements for legal characters, with no whitespace characters allowed. Additionally, from XML specification: disallowed initial characters for Names include numeric digits, diacritics (letter with accent or marking), the "." period character (sometimes called full stop) and the "-" hyphen character. For further information see X3D Scene Authoring Hints: Naming Conventions <https://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html#NamingConventions> .
*	NMTOKENS <https://www.w3.org/TR/REC-xml/#sec-common-syn>  is an XML term for an array of NMTOKEN <https://www.web3d.org/x3d/content/X3dTooltips.html#NMTOKEN>  values.

b.	x3d.py

 

*	PyPi package x3d 4.0.64.4
*	https://pypi.org/project/x3d
*	https://www.web3d.org/x3d/stylesheets/python/x3d.py

 

You will not find xs:NMTOKEN anywhere in x3d.py.  Here is excerpt showing DEF and USE handling:

 

class _X3DNode:

    """

    All instantiable nodes implement X3DNode, which corresponds to SFNode type in the X3D specification.

    """

    # [… snip …]

    @property # getter - - - - - - - - - -

    def DEF(self):

        """ Unique ID name for this node, referenceable by other X3D nodes. """

        return self.__DEF

    @DEF.setter

    def DEF(self, DEF):

        if  DEF is None:

            DEF = SFString.DEFAULT_VALUE()

        assertValidSFString(DEF)

        self.__DEF = str(DEF)

        if self.__DEF:

            self.__USE = None # DEF and USE are mutually exclusive

    @property # getter - - - - - - - - - -

    def USE(self):

        """ Reuse an already DEF-ed node ID, excluding all child nodes and all other attributes. """

        return self.__USE

    @USE.setter

    def USE(self, USE):

        if  USE is None:

            USE = SFString.DEFAULT_VALUE()

        assertValidSFString(USE)

        self.__USE = str(USE)

        if self.__USE:

            self.__DEF = None # DEF and USE are mutually exclusive

 

I have added a SourceForge ticket to provide further data-validity checks in x3d.py some day.

 

*	X3D sourceforge ticket #23, x3d.py validation of DEF, USE, name values 
*	https://sourceforge.net/p/x3d/tickets/23
*	x3d.py handling of DEF, USE and name values does not include any special typing restrictions such as those provided by the XML type xs:NMTOKEN. Such checks need to be added for stricter handling and detection of illegal values.

 

X3DUOM will continue to define appropriately using xs:NMTOKEN since it is the strictest valid type.  Derivative libraries are welcome to adapt in the best fashion possible.  There are over 4000 correctly working models in the X3D Examples Archives that demonstrate the current libraries are working satisfactorily.  Each example model is easily reviewed.

 

*	X3D Resources, X3D Examples Archives
*	https://www.web3d.org/x3d/content/examples/X3dResources.html#Examples

 

If you are creating alternate variations of X3DUOM or X3DPSAIL or X3DJSAIL open source, please do not use the same name since they are not the same libraries.

 

My current focus of effort is upgrading the 19776-2 X3D XML encoding specification to version 4.0, together with Dick Puk, as the original email message reports.

 

Subject line changed and cc: list trimmed since your post (and this detailed response) are not related to original post on the X3D XML Encoding.

 

Good luck with your efforts.

 

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 https://faculty.nps.edu/brutzman

 

From: John Carlson <yottzumm at gmail.com> 
Sent: Saturday, February 24, 2024 10:33 AM
To: Extensible 3D (X3D) Graphics public discussion <x3d-public at web3d.org>
Cc: Brutzman, Donald (Don) (CIV) <brutzman at nps.edu>; Web3D Consortium <consortium at web3d.org>; bod at web3d.org; x3d at web3d.org
Subject: Re: [x3d-public] X3D 4.0 update to XML encoding has commenced, comments welcome

Don,

 

I would like to see name attribute types handled consistently.  I believe there are at least 6 cases where type=‘xs:NMTOKEN’ and baseType=‘xs:NMTOKEN’ and xs:NMTOKEN gets puts into x3d.py in type expressions, and that breaks x3d.py (colon is not recognized).

 

Primarily this has been an issue with my version of the x3d.py, but I have been fixing upstream code to change to type=‘SFString’.

 

I believe the change was made when you incorporated Holger’s changes.

 

Please verify that all xs:NMTOKEN references in x3d.py are correct.   My suggestion is attempt to modify upstream files like the X3DPSAIL stylesheet, X3DUOM and XML schema.

 

I have provided updates to X3DUOM which allow my version of X3DPSAIL to work.  Other patches are more difficult .

 

Getting this right is vital to the success of a Blender exporter using X3DPSAIL.

 

Call me or set a meeting to discuss the changes as I am out of my element.  It’s highly likely you may have patched them already since 1-2 weeks ago.  It’s difficult running with tons of unapplied patches.

 

I will look into repairing X3DPSAIL if you view this a non-issue for the XML spec.

 

John

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20240224/a6b01aeb/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5464 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20240224/a6b01aeb/attachment-0001.p7s>


More information about the x3d-public mailing list