[x3d-public] agreement on number of \\\\\\\\ in Java???? X3DJSAIL.

Don Brutzman brutzman at nps.edu
Sun Jul 30 10:15:03 PDT 2017


Mantis issue tracking by working-group members keeps track of details, alternatives and resolution for each specification issue.
	http://www.web3d.org/x3d/content/examples/X3dResources.html#Feedback
	http://www.web3d.org/realtime-3d/member-only/mantis/my_view_page.php

Web3D membership and participation is always welcome, more engagement helps us all work through to progress even faster.

	http://www.web3d.org/join

FYI here is current issue 1091 on this topic.  No doubt further updates will come from this thread.  Thanks for ongoing efforts!

======================================================================
A NOTE has been added to this issue.
======================================================================
http://www.web3d.org/member-only/mantis/view.php?id=1091
======================================================================
Reported By:                walroy
Assigned To:                brutzman
======================================================================
Project:                    X3D
Issue ID:                   1091
Category:                   19776-1 (XML)
Reproducibility:            N/A
Severity:                   minor
Priority:                   normal
Status:                     acknowledged
======================================================================
Date Submitted:             2016-12-08 10:46 GMT
Last Modified:              2017-07-30 14:45 BST
======================================================================
Summary:                    5.15 SFString and MFString - Confusion between XML
and X3D syntax for SFString
Description:
Comment on 19776-1: XML Encoding - V3.3
5.15 SFString and MFString
http://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/EncodingOfFields.html#SFString

-----------------
Confusion between xml and x3d syntax for SFString

Problem statement: 5.15 states which kind of quotes should be used for the xml
attribute value for SFString and MFString. But that's specified in the xml
standard: both single quotes and double quotes are valid. When an XML-encoded
X3D file is parsed by a generic XML parser, there is no way to know which kind
of quote was used, and that shouldn't be necessary. For an SFString, str="foo"
or str='foo' should both be valid; and for an MFString, str='"foo" "bar"' or
str=""foo" "bar"".

Suggested solution: replace
SFString specifies a single string encoded as a sequence of UTF-8 octets
enclosed in double quotes (e.g., "string").  The MFString specifies zero or more
SFStrings enclosed in single quotes (e.g., '"string1" "string2"')
with
SFString specifies a single string encoded as a sequence of UTF-8 octets without
additional quotes (as an XML attribute value, it must be enclosed in single or
double quotes, e.g. "string" or 'string').  The MFString specifies zero or more
SFStrings, each of them enclosed in double quotes, separated by at least one
space (as an XML attribute value, it must be enclosed in single or double
quotes, and conflicting single and double quotes in the content must be written
as entities; e.g., '"string1" "string2"'; for more complicated cases with single
quotes in the first string and double quotes in the second string,
'"\"string1\"" "'string2'"' or ""\"string1\"" "'string2'"')

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


Additional Information:
Submitted on Wednesday, 2016,  December 7 - 4:03pm
by  (Yves Piguet )
IP: 178.196.7.81

See: http://www.web3d.org/node/1694/submission/1108

======================================================================
Relationships       ID      Summary
----------------------------------------------------------------------
related to          0001071 5.15 SFString and MFString - Blank norm...
related to          0000705 5.15 SFString and MFString - Escaping b...
related to          0000488 5.15 SFString and MFString - Handling o...
======================================================================

----------------------------------------------------------------------
  (0001675) walroy (developer) - 2016-12-08 10:53
  http://www.web3d.org/member-only/mantis/view.php?id=1091#c1675
----------------------------------------------------------------------
This "feature" (or would that be 'feature') has been a point of discussion and
argument since the XML encoding was first introduced. To keep consistent with
VRML (Classic VRML), the elements of MFString are quoted ("). This doesn't
prevent a user from quoting (with ") the entire attribute value. That would
force using the entity format for individual elements:

mfString=""element-1" "element-2"
"element-3" ... " ... />

This format gets messy, especially if there are a lot of special characters that
need to be converted to entities.

An entirely new way that is more XML-/HTML-centric would be to use child
elements

<Node ...>
      <mfString>element-1</mfString>
      <mfString>element-2</mfString>
      <mfString>element-3</mfString>
                   :
                   :
</Node>

The above format is nice because it is also CDATA-friendly

Submitted by Leonard Daly on 7th December 2016
http://web3d.org/mailman/private/x3d_web3d.org/2016-December/005460.html

----------------------------------------------------------------------
  (0001676) walroy (developer) - 2016-12-08 10:57
  http://www.web3d.org/member-only/mantis/view.php?id=1091#c1676
----------------------------------------------------------------------
My comment was just about the wording of 19776-1 V3.3: the XML encoding should
just be valid XML, and you cannot add requirements on that part because (i) it's
useless; and (ii) XML libraries usually don't let you specify or read them.

On the other hand, I agree that storing SFString and MFString field values in
XML nodes would be convenient; but that would be an extension for a future
revision of the X3D standard. I'd rather have an XML tag name like <value ...>
or <fieldvalue ...> to avoid confusion with X3D nodes; and a more general
mechanism which allows any field type, nice for large arrays. There is also the
issue of white space normalization in XML attributes, which in SFString and
MFString forces you to use X3D escape sequences for spaces, tabs and line
breaks; mixing them with xml entities is ugly. The exception of allowing cdata
only for the url field of Script nodes isn't very satisfactory. Actually I can't
even find where this exception is clearly stated in 19776-1, except en passant
in 6.2.179 without explanation (this might call for another spec comment...)

Originally submitted by Yves Piguet on 7th December 2016
Forwarded by Roy Walmsley to the X3D list 8th December 2016
http://web3d.org/mailman/private/x3d_web3d.org/2016-December/005460.html

----------------------------------------------------------------------
  (0001678) walroy (developer) - 2016-12-09 10:43
  http://www.web3d.org/member-only/mantis/view.php?id=1091#c1678
----------------------------------------------------------------------
Hopefully the quotes are all matching your original intent.

Please note that an XML parser will accept str='"foo" "bar"' satisfactorily, but
attribute

a.	str=""foo" "bar""

gets terminated at the first str="" and the remainder will throw a parse error
as malformed content.

Candidate replacements that are legal XML:

b.	str='"foo" "bar"'
and
c.	str=""foo" "bar""

Option b is preferred if using X3D Canonical Form, perhaps for digital signature
or encryption.  Readable too.

Note that in general, any "user agent" program handling the XML may choose to
represent as either form, and the author has no particular choice at that point.

So we have to be careful not to get overzealous and try to mandate some XML
behaviors over which we have no control.

Further backslash and escaping contortions may occur if the strings themselves
include \" escaped quotes as content.

Please check out the explanations in _X3D for Web Authors_ and especially the
slides/examples.  X3D-Edit has a bunch of user-assist work going on behind the
scenes to help authors in this regard.  The X3D Validator (X3D Schema, X3D
Schematron) attempts to apply regexes to detected malformed MFString
expressions; improvements may be possible.

http://x3dgraphics.com/slidesets/X3dForWebAuthors/Chapter02-GeometryPrimitives.pdf
(slides 82-89)

http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter02-GeometryPrimitives/TextSpecialCharactersIndex.html

Reassuring: we have not yet found an MFString that cannot be represented.  Test
cases welcome.

Also reassuring is that we are just talking about the XML encoding - DOM
handling and other encoding/language representations for X3D are simpler.

Hesitation is suggested before thinking that an easier solution is possible,
since escaping designs are always subtle/complex and all existing content and
tools will still need to be supported.

Submitted by Don Brutzman on 8th December 2016
http://web3d.org/mailman/private/x3d_web3d.org/2016-December/005469.html

----------------------------------------------------------------------
  (0001679) walroy (developer) - 2016-12-09 10:46
  http://www.web3d.org/member-only/mantis/view.php?id=1091#c1679
----------------------------------------------------------------------
p.s. found further relevant references

	Metacharacter
	https://en.wikipedia.org/wiki/Metacharacter

> In many programming languages, strings are delimited using quotes. In some
cases, escape characters (and other methods) are used to avoid delimiter
collision. Example : "He said : \"Hello\"".

	Delimiter collision
	https://en.wikipedia.org/wiki/Delimiter_collision
	

------------------------
Submitted by Don Brutzman on 8th December 2016
http://web3d.org/mailman/private/x3d_web3d.org/2016-December/005471.html

----------------------------------------------------------------------
  (0002085) walroy (developer) - 2017-07-30 14:45
  http://www.web3d.org/member-only/mantis/view.php?id=1091#c2085
----------------------------------------------------------------------
The proposed change to the specification (all to the section
http://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/EncodingOfFields.html#SFString)
would be to change this part:

-----------

   The MFString specifies zero or more SFStrings enclosed in single quotes (e.g.,
'"string1" "string2"').

   NOTE  The construct

"string3"

is not a valid instance of an MFString. Such an MFString would be properly
specified as

'"string3"'

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

into this:

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

The MFString specifies zero or more SFStrings, with each single string enclosed
in double quotes (e.g., "string1" "string2"). Note that inside an XML attribute,
you have to express a double quote using the " character entity, unless you
enclose a whole XML attribute in single quotes.

   NOTE  The construct

"string3"

is not a valid instance of an MFString. Such an MFString would be properly
specified as

'"string3"'

or

'"string3"'

or

""string3""

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

------------------------------------------------------------------------------
For additional clarity, I would also add more prose and examples to
explain when backslashes are needed. So I would change

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

EXAMPLE 2  Two instances of the double quote are contained in the following
SFString field string:

<Text string='"He said, \"Immel did it!\""' />

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

with this:

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

If a string is part of an MFString, and you want this string to contain a
double-quote (for example, to actually show a double-quote using the Text node
field "string") then you have to place a backslash before this double-quote.
This rule applies regardless if you express double-quote as " or as " .
This is necessary, to avoid treating the double-quote as a delimiter of strings
on a MFString list.

Consequently, if you want a string inside MFString to contain a backslash (for
example, to actually show a backslash using the Text node field "string") then
you have to write two backslashes. This is necessary, to avoid accidentally
changing the meaning of a following double-quote character.

EXAMPLE 2  All the following forms are correct and equivalent:

<Text string='"He said, \"Immel did it!\""' />

<Text string='"He said, \"Immel did it!\""' />

<Text string='"He said, \"Immel did it!\""' />

<Text string=""He said, \"Immel did it!\""" />

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

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

--------------
   SFString specifies a single string encoded as a sequence of UTF-8 octets
enclosed in double quotes (e.g., "string").

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

could be changed to

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

   SFString specifies a single string encoded as a sequence of UTF-8 octets. It
is simply the value of an XML attribute. As such, following XML rules, it can be
surrounded either in single-quotes (apostrophes) or double quotes.

The following examples of an SFString are all valid:

"string"
'string'
"string "with some quotes inside""
'string "with some quotes inside"'
'string "with some quotes inside"'

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

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

Submitted as text "corrections.txt" by Michalis Kamburelis on May 10th 2017

Issue History
Date Modified    Username       Field                    Change
======================================================================
2016-12-08 10:46 walroy         New Issue
2016-12-08 10:51 walroy         Relationship added       related to 0001071
2016-12-08 10:51 walroy         Relationship added       related to 0000705
2016-12-08 10:51 walroy         Relationship added       related to 0000488
2016-12-08 10:53 walroy         Note Added: 0001675
2016-12-08 10:57 walroy         Note Added: 0001676
2016-12-09 10:43 walroy         Note Added: 0001678
2016-12-09 10:46 walroy         Note Added: 0001679
2016-12-30 21:10 brutzman       Assigned To               => brutzman
2016-12-30 21:10 brutzman       Status                   new => acknowledged
2017-07-30 14:45 walroy         Note Added: 0002085
======================================================================

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