[x3d-public] MFString quoting [was: interesting sample]
Michalis Kamburelis
michalis.kambi at gmail.com
Tue Apr 25 20:15:36 PDT 2017
2017-04-26 4:10 GMT+02:00 Andreas Plesch <andreasplesch at gmail.com>:
> I don't think the X3D disallows using double quotes to surround XML
> attributes in X3D XML encoding. Indeed, the specification (
> http://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/EncodingOfFields.html#SFString
> ) does not show this as a valid example (it only shows using single
> quotes to surround the XML attribute). But it also doesn't say it's
> invalid.
>
>
> (Unfortunately) it does say explicitly:
>
> The MFString specifies zero or more SFStrings enclosed in single quotes
> (e.g., '"string1" "string2"').
Hm, indeed. You're right!
It looks that when reading this, I instinctively corrected it in my
mind to mean something else, assuming that there's no way the X3D
specification could disallow a syntax that is correct XML (and does
not limit X3D features in any way).
To everyone: So, can we fix the specification, please?:) I can bet that
all existing implementations already follow a more relaxed version,
where
<Text string=""blablah"" />
is allowed. If in doubt, you can check the test
https://raw.githubusercontent.com/castle-engine/demo-models/master/x3d/test_mfstring_quotes.x3d
in your favorite X3D browser --- I know it works in view3dscene and
X3DOM (in the latter case it's the browser that actually parses the
XML, I checked Firefox and Google Chrome).
> If double quotes are used for outer quotes, it may become impossible to
> identify
>
> " ' MFString or SFString ? ' "
>
> as MFString or SFString. But I do not think this would be a problem since it
> would be parsed according to what the field expects. Is there a situation
> where it is necessary to uniquely identify a field value type based on the
> value alone ?
Luckily, there is no such situation. When parsing a field, you always
100% know whether it's MFString or SFString. It even includes the
situations when you parse an "interface declaration" (custom fields
within Script or shader nodes) and prototypes -- the field type is
always explicitly given somewhere.
So
" ' MFString or SFString ? ' "
is either
- an incorrect MFString (you cannot use ' to delimit parts within MFString)
- a correct SFString that happens to start and end with an apostrophe.
Regards,
Michalis
More information about the x3d-public
mailing list