[x3d-public] interesting sample

Michalis Kamburelis michalis.kambi at gmail.com
Tue Apr 25 11:44:39 PDT 2017


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"' />

or

<Text string=""blablah"" />

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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_quotes_0.png
Type: image/png
Size: 97947 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170425/71529e1a/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_quotes.x3d
Type: application/vnd.hzn-3d-crossword
Size: 929 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170425/71529e1a/attachment-0001.x3d>


More information about the x3d-public mailing list