[x3d-public] MFString quoting [was: interesting sample]

Andreas Plesch andreasplesch at gmail.com
Wed Apr 26 08:49:08 PDT 2017


Michalis, thanks for taking the time to explain the issues more clearly.

On Wed, Apr 26, 2017 at 10:55 AM, Michalis Kamburelis <
michalis.kambi at gmail.com> wrote:

> 2017-04-26 16:10 GMT+02:00 Andreas Plesch <andreasplesch at gmail.com>:
> >
> >
> > On Apr 25, 2017 11:16 PM, "Michalis Kamburelis"
> >
> > So
> >
> >   " ' MFString or SFString ? ' "
> >
> > is either
> > - an incorrect MFString (you cannot use ' to delimit parts within
> MFString)
> >
> >
> > Yes, you are right, that is incorrect. But that brings up SFStrings.
> >
> > When not used as part of an MFString, they still have the double quote
> > requirement while XML allows both single or double quotes.
>
> Indeed, the specification sentence
>
> """"
>   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"'
> """"
>
> >
> > So, I would suggest to allow single quotes as delimiters in MFStrings as
> > well although I realize that places an additional burden on the x3d
> parser.
> >
> > In the end, to me, allowing balanced pairs of single or double quotes
> > interchangeably anywhere is the simplest rule. Backslash escaping for
> > printing is required in any case.
> >
>
> I would find it useful too. But this is a different change to the
> spec, and one that is not so 100% secure.
>
>
Yes, this would be a bigger change but perhaps worth it ?


> 1. In a perfect world, it should be possible to add this possibility
> to the specification, because
>
>   " 'one' 'two' "
>
> is an an invalid MFString now. So the new X3D XML readers could see
> that "oh, it starts with an apostrophe, it must be an MFString using
> that new feature of enclosing parts in apostrophes". Unfortunately,
> because of a large number of incorrect X3D examples on the Internet,
> most X3D XML right now check whether the string starts and ends with
> double-quotes, and if not -- they assume it's an invalid MFString, and
> parse it as SFString, and use the contents as an MFString with count =
> 1.
>
> So
>
>   <Text string=" 'blahblah' " />
>
> right now causes the display of apostrophes (and a warning in the
> console). After your change, it would be displayed without
> apostrophes.
>

Right now, it would be invalid. Browsers would typically just receive
'blahblah' from the xml parser as value.
They may or may not decide to display the apostrophes or anything at all.
After my change, it would be displayed without apostrophes which I think
would be the expectation by most.


> True, it will probably not affect much scenes in practice... Still,
> it's not a 100% secure change. Unlike the initial idea of only fixing
> the spec to conform to XML to allow the whole XML attribute be
> surrounded by ' or " .
>
> 2. As Yves notes, the current rule is also consistent with classic
> encoding (and VRML). Right now, my MFString handling in view3dscene is
> just firing up a VRML lexer to interpret the MFString attribute
> contents. With your change, we either also change the classic
> encoding, or we need a little different code to handle MFString in XML
> encoding.
>
> Neither 1. or 2. are a large disadvantage in my eyes, so I'm not
> refusing this change. I'm only saying that it's a little more
> intrusive change than the simpler plan to "just fix the specification
> to allow what XML allows".
>
>
Completely agreed and maybe the change would be too intrusive.


> >> Backslash escaping for printing is required in any case.
> >
> > I don't understand that part.
>
>
I apologize for the very abbreviated statement. Thanks, Michalis, for
explaining this much better.


> If I may, I think I can explain what Andres meant:
>
> You must already use double backslashes to get a single visible
> backslash in MFString. After the Andreas proposed change, you would
> need to protect single-quotes (apostrophes) by backslashes, but that's
> not a problem (it does not cause an incompatibility for correct X3D
> scenes), because all the backslashes in current X3D scenes are either
> doubled (to mean a single backslash) or they are used to protect the
> following character.
>
> Consider this example:
>
>   <Text string=""here is \'text surrounded in apostrophes\'"" />
>
> Right now it's either incorrect (if you don't think that backslash
> before apostrophe is valid) or correct (and no backslashes will be
> visible).
>
> After the proposed Andreas change, this example will always be correct
> (and no backslashes will be visible), since then the apostrophes will
> need to be (in some situations) protected. So, no compatibility was
> broken.
>
> Regards,
> Michalis
>



-- 
Andreas Plesch
39 Barbara Rd.
Waltham, MA 02453
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170426/de8bf3ab/attachment-0001.html>


More information about the x3d-public mailing list