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

Leonard Daly Leonard.Daly at realism.com
Tue Apr 25 20:41:57 PDT 2017


Pretty much since the beginning there has been discussions as to the 
"correct" way to specify an MFString. That tells me we (the WG) could 
improve the notation and/or description for MFStrings. Note that the 
confusion only seems to be in the XML encoding.

Part of the syntax was a desire to maintain compatibility with the old 
VRML97 encoding. In that encoding all string elements were enclosed in 
quotes ("). Since this encoding was not trying to fit into another 
format, it was easy to do some things -- like use a external (meaning 
not in quotes) space for a delimiter. The value of SFString would be 
encoded as

    "this is a single string element"

and the value of an MFString field would be encoded as

    "this" "is" "a" "multiple" "string" "element"

When X3D went to XML, the quotation marks around field elements was 
retained as was the white-space separator. As was the case for almost 
everything else, it was put in an attribute. XML rules require all 
attribute values to be enclosed in a quote (") or apostrophe ('). This 
made the encodings of the SFString and MFString


    '"this is a single string element"'

    '"this" "is" "a" "multiple" "string" "element"'

But this is XML and all that really counts is how the attribute value is 
presented to the parser. You can use various entities to represent any 
of the values in the attribute value. If there is a reason that all 
attribute values must be contained in quotes (perhaps it is a style 
requirement), then an MFString would be encoded as

""this" "is" "a" "multiple" 
"string" "field""

Yes it's messy. We thought it was well documented, but the repeated 
discussion has shown that not to be the case.


So how would you change the encoding or documentation to make things better?

There are many possibilities for changing the encoding. I'll just list a 
few for MFString

<text>
     <string>This</string>
     <string>is</string>
     <string>a</string>
     <string>multiple</string>
     <string>string</string>
     <string>element</string>
</text>

<text><![CDATA[This
is
a
multiple
string
element]]></text><!-- newlines delimit the string elements -->

Allow any character to delimit string elements. The entire string would 
still need to be handled as an XML attribute. The opening character 
defines the closing character.

    "'This' |would| ^be^ ~legal~"


I am not recommending any of these, just trying to offer a few 
alternatives to see what people might come up with.


Leonard Daly




>
>
> On Apr 25, 2017 8:37 PM, "Michalis Kamburelis" 
> <michalis.kambi at gmail.com <mailto:michalis.kambi at gmail.com>> wrote:
>
>     2017-04-26 1:47 GMT+02:00 Andreas Plesch <andreasplesch at gmail.com
>     <mailto:andreasplesch at gmail.com>>:
>     >> 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
>     <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.
>     >
>
>     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
>     <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"').
>
> There may be a little wiggle room since double quotes are not declared 
> invalid, but in general the spec. does not deal with negatives. 
> Otherwise, one could argue using $$ may be valid as well. Also, the 
> words "single quotes" clearly refer to apostrophes rather than single 
> counts of quote characters.
>
> 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 ?
>
>
>     I admit, I may be biased when reading this part of the specification,
>     because I think (like you) that it would be weird if the X3D
>     specification was limiting what is valid XML syntax. Probably everyone
>     uses some standard library to read XML files, and we don't know:
>
>     - What character in XML was used to surround XML attribute: single or
>     double quote.
>     - What characters in XML were used to express a visible double quote:
>     " or ".
>
>     And we don't want to know it, after all it's the purpose of a standard
>     XML parser to hide these details from the programmers working on a
>     higher level.
>
>     Indeed, it would be great if the X3D XML specification clarified this,
>     both by more prose and by showing more examples what is correct and
>     what is incorrect (like the examples in my previous mail). Reading the
>     thread from
>     http://web3d.org/pipermail/x3d-public_web3d.org/2017-March/006145.html
>     <http://web3d.org/pipermail/x3d-public_web3d.org/2017-March/006145.html>
>     , it seems that everyone agrees about what the specification *should*
>     mean (regardless of what it currently means), and this expectation
>     matches (all?) current implementations. So it would be great to
>     improve/fix the specification:)
>
>
> Completely agreed.
>
> As an aside, I recently came across glitch.com <http://glitch.com> 
> which has an online html editor with non-optional syntax checker. It 
> insists on double quotes for attribute values which was irritating in 
> the same way.
>
> Andreas
>
>
>
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org


-- 
*Leonard Daly*
3D Systems & Cloud Consultant
LA ACM SIGGRAPH Chair
President, Daly Realism - /Creating the Future/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170425/180f7f82/attachment-0001.html>


More information about the x3d-public mailing list