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

Andreas Plesch andreasplesch at gmail.com
Tue Apr 25 16:47:41 PDT 2017


It turns out that quoting is regularly discussed. The latest round was just
a month ago:

http://web3d.org/pipermail/x3d-public_web3d.org/2017-March/006145.html

but looking through the archives there are more threads.

Date: Tue, 25 Apr 2017 20:44:39 +0200

> From: Michalis Kamburelis <michalis.kambi at gmail.com>
> To: John Carlson <yottzumm at gmail.com>
> Cc: X3D Graphics public mailing list <x3d-public at web3d.org>
> Subject: Re: [x3d-public] interesting sample
>
> 2017-04-25 10:03 GMT+02:00  <yottzumm at gmail.com>:
> > Here?s an interesting sample from X3D resources examples  that many
> viewers
> > don?t handle?they don?t list the whole MFString.
> >
>
> view3dscene handles it. Also displays a warning, pointing to the problem:
>
>   view3dscene: VRML/X3D warning: Error when reading MFString field
> "string" value. Possibly missing double quotes (treating as a single
> string): Error at line 1 column 134: Expected string, got "is"
>
> More explanation:
>
> - Text.string is MFString.
>
> - So the whole content must be surrounded with double-quote
> characters, if you want to place a single string inside.
>
> - To place a *visible* double-quote inside, it must *always* be
> protected with a backslash.
>
> - The double-quote can be expressed as " or " inside XML
> attribute. These are equivalent once XML parser is done, so they are
> seen as equivalent for X3D browser. Note that you can only use literal
> " if you surround the whole XML attribute with a single quote
> (apostrophe, '), otherwise you have to use " -- that's how XML
> works.
>
> - Note that the XML attribute can be surrounded with single quote
> (apostrophe, ') or double quote ("). This is a feature of XML, not
> X3D. I was careful to always use the words "double quotes" above, when
> I meant only double quotes.
>
> Following the above rules makes your X3D correct. Other options may
> also work in some X3D browsers, because we have learned to tolerate
> incorrect X3D files... but this tolerance results in different
> behavior in complicated cases, like the one you show.
>
> And yes, I wish that X3D specification about XML encoding was more
> clear about this (maybe using more examples, like I show below). The
> example X3D files found on the Internet also often show something
> incorrect. Disclaimer: My explanation above, and examples below, is
> *my* understanding of the specification, and describes also
> view3dscene implementation, and it was confirmed by testing with other
> browsers long time ago.
>
> For example:
>
> <Text string="blablah" />
>
> is INCORRECT.
>
> To make it CORRECT, write
>
> <Text string=' "blablah" ' />
>
> or
>
> <Text string='"blablah"' />
>
>
Using single quotes as outer quotes is legal,


> or
>
> <Text string=""blablah"" />
>
>
but using double quotes is not in X3D:
http://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/EncodingOfFields.html#SFString

although it is legal in XML.

However, most browser probably allow double quotes as outer quotes since
they will just use a standard XML parser.
I am not pretending to understand the motivation for this X3D rule.

To place a (*visible*) double-quote inside, precede it with backslash. So
>
>
<Text string='"You will see quotes \"around this string\""' />
>
> or
>
> <Text string='"You will see quotes \"around this
> string\""' />
>
> or
>
> <Text string='"You will see quotes \"around this string\""' />
>
> I'm attaching an X3D file testing all these possibilities. This is
> correct X3D as far as I know, and should work in all X3D browsers. (If
> it doesn't, please let me know so that I can update my knowledge:).
>
> 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/20170425/37d6a305/attachment.html>


More information about the x3d-public mailing list