[x3d-public] X3dToJson.xslt still removing spaces from comments. See this output from Java compared to JavaScript and JavaScript output

Don Brutzman brutzman at nps.edu
Sun Jan 21 20:59:43 PST 2018


X3D Canonical Form says that whitespace is normalized, and X3DJSAIL output attempts to follow that.  The first of the following rules can be interpreted that way, though I'm not seeing explicit mention of comments.

X3D Compressed Binary Encoding: 4.2.3 X3D canonical form
http://www.web3d.org/documents/specifications/19776-3/V3.1/Part03/concepts.html#X3DCanonicalForm

====================
a. Whitespace rules:

     All whitespace characters are converted to a normalized (single-occurrence) blank character.
     Whitespace includes comma separators between all MF-type array values, including MFString arrays.
     All literal characters within an SFString value are retained verbatim.
     All literal characters within MFString array values are retained verbatim.
====================

I thought another prior requirement might be in XML Recommendation or XML Infoset, but didn't find it...

XML Information Set (Second Edition)
http://www.w3.org/TR/xml-infoset

Extensible Markup Language (XML) 1.0 (Fifth Edition)
https://www.w3.org/TR/xml

Not sure where the excess whitespace is getting stripped, didn't find anything like that in the CommentsBlock source.

Wouldn't surprise me if DOM loader was doing that, in which case it can't be "fixed" or retained any differently - confirmation or further sleuthing welcome..

In practice I have seen tools normalize whitespace.  Seems like a good practice, you don't want invisible characters (or tool idiosyncrasies independently deciding that strictly equivalent information in a model might vary in terms of whitespace.  That's bad for digital signature, encryption, security back doors, etc.

So, if anything, I'd lean towards explicitly requiring the normalization of whitespace in comments for X3D Canonical Form.


On 1/20/2018 10:29 PM, John Carlson wrote:
> See subject.  Excess spaces are being removed from comments in JSON output from X3DJSAIL.
> 
> $ diff HelloWorldProgramOutput.Nashorn.x3d HelloWorldProgramOutput.Nashorn.js.new.x3d
> 
> 73c73
> 
> <                     <!-- Comment example A, plain quotation marks:  He said, "Immel did it!" -->
> 
> ---
> 
>  >                     <!-- Comment example A, plain quotation marks: He said, "Immel did it!" -->
> 
> 112a113
> 
>  >
> 
> 230a232
> 
>  >
> 
> 248,252c250
> 
> <         <!-- Test success: x3dModel.findNodeByDEF(DeclarativeAppearanceExample) = <Appearance DEF='DeclarativeAppearanceExample'/> i.e.
> 
> < <Appearance DEF='DeclarativeAppearanceExample'>
> 
> <     <!- - DeclarativeMaterialExample gets overridden by subsequently added MaterialModulator ProtoInstance - ->
> 
> <     <ProtoInstance DEF='MyMaterialModulator' name='MaterialModulator' containerField='material'/>
> 
> < </Appearance> -->
> 
> ---
> 
>  >         <!-- Test success: x3dModel.findNodeByDEF(DeclarativeAppearanceExample) = <Appearance DEF='DeclarativeAppearanceExample'/> i.e. <Appearance DEF='DeclarativeAppearanceExample'> <!- - DeclarativeMaterialExample gets overridden by subsequently added MaterialModulator ProtoInstance - -> <ProtoInstance DEF='MyMaterialModulator' name='MaterialModulator' containerField='material'/> </Appearance> -->
> 
> 255c253
> 
> <         <!-- Test success: x3dModel.findElementByNameValue("MaterialModulator", "ProtoDeclare")  found -->
> 
> ---
> 
>  >         <!-- Test success: x3dModel.findElementByNameValue("MaterialModulator", "ProtoDeclare") found -->
> 
> 279,284c277,282
> 
> <         <!-- Test success:  AnchorObject.isNode()=true,              siteAnchor.isNode()=true -->
> 
> <         <!-- Test success:  AnchorObject.isStatement()=false,        siteAnchor.isStatement()=false -->
> 
> <         <!-- Test success:   ROUTEObject.isNode()=false,     orbitPositionROUTE.isNode()=false -->
> 
> <         <!-- Test success:   ROUTEObject.isStatement()=true, orbitPositionROUTE.isStatement()=true -->
> 
> <         <!-- Test success: CommentsBlock.isNode()=false,           testComments.isNode()=false -->
> 
> <         <!-- Test failure: CommentsBlock.isStatement()=true,      testComments.isStatement()=true -->
> 
> ---
> 
>  >         <!-- Test success: AnchorObject.isNode()=true, siteAnchor.isNode()=true -->
> 
>  >         <!-- Test success: AnchorObject.isStatement()=false, siteAnchor.isStatement()=false -->
> 
>  >         <!-- Test success: ROUTEObject.isNode()=false, orbitPositionROUTE.isNode()=false -->
> 
>  >         <!-- Test success: ROUTEObject.isStatement()=true, orbitPositionROUTE.isStatement()=true -->
> 
>  >         <!-- Test success: CommentsBlock.isNode()=false, testComments.isNode()=false -->
> 
>  >         <!-- Test failure: CommentsBlock.isStatement()=true, testComments.isStatement()=true -->
> 


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