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

Roy Walmsley roy.walmsley at ntlworld.com
Thu Apr 27 07:10:34 PDT 2017


Vince,

What would be helpful to understand your requirements is to work through an
example. So, taking you listed some text that reads :

	cylindrical_surface("name",'#34')

We can consider this to be 'plain text'. I then assume you want this to be a
metadata. I'll assume you want it to be the sole element in the "value"
field of a MetadataString node. And, furthermore, that we want to express
this in an XML encoding. This is what it might look like using the
specification standard single / double quotes:

	<MetadataString name="example"
value='"cylindrical_surface(\"name\",'#34')"'/>

So I tried this, and it failed validation in XMLSpy. I had to change it to
the following to get it to validate:

	<MetadataString name="example"
value='"cylindrical_surface(\"name\",'#34')"'/>

Finally, I checked validation against the X3D online validator. It passed
that too.

Perhaps you have more complex usage in mind. Please expand, if so.

Roy


-----Original Message-----
From: x3d-public [mailto:x3d-public-bounces at web3d.org] On Behalf Of Vincent
Marchetti
Sent: 27 April 2017 14:39
To: Andreas Plesch <andreasplesch at gmail.com>; Don Brutzman
<brutzman at nps.edu>; X3D Graphics public mailing list <x3d-public at web3d.org>
Subject: Re: [x3d-public] MFString quoting [was: interesting sample]

I should have emphasized that the 'does something' in step 2 is non-trivial,
it has to be a mapping that makes it possible to perform step -3
unambiguously in the reading of X3D files. However, the point of my list of
steps is that step 2 doesn't concern itself with & , ', <,>, or non-ascii
characters, we count on the XML library to handle those correctly.


> On Apr 27, 2017, at 9:26 AM, Vincent Marchetti <vmarchetti at kshell.com>
wrote:
> 
> I've been lurking on this thread because it is pertinent to the Metadata
workshop being offered at Web3D 2017.
> 
> I would like to formulate best practices so that fairly arbitrary text
values can be placed as values in the value field of a MetadataString.
> For example, for the application that stores references into a STEP 
> CAD file there may be a value (line returns not important)
> 
> cylindrical_surface("name",'#34')
> 
> 
>  -- name can be any unicode string
>  -- the distinction between apostrophes and quotes is important
> 
> I would like to get to the point where we can advise users that X3D
Metadata capabilities can handle this, and the implementation involves:
> 
> 1. Start with your metadata value as an array of unicode string (it's 
> an array because the value in MetadataString is MFString. Often it 
> will be  an array of one element ) 2. Apply a reversible unicode ->
unicode mapping to each element of the array that "does something" to quote
characters ( Need to clarify what 'does something' is ) 3. wrap each mapped
string from step 2 in quotes, and concatenate them all with white space
separation. The result is a unicode string.
> 4. Pass the result unicode string into your favorite compliant XML code
library to put it into an XML attribute; and then output the whole XML file
as a byte stream in utf-8 encoding.
> 
> To reverse
> -4 Read your byte stream with a compliant XML library, extract the 
> value of the MetadataString value attribute as a unicode string
> -3 Parse the string, based on quotes and white spaces, to get an array 
> of unicode strings
> -2 reverse the mapping of step 2 above to retrieve your all-important 
> quotes
> -1 Voila, you have your original list of unicode strings, again. Often 
> it will be an array of one element
> 
> The fact that XML libraries will tend to make the attribute value in the
XML text a horrible mash of &-escape sequences I accept as a price to pay.
> 
> 
> If a member of the audience were to ask why the value in a 
> MetadataString  is MFString and not SFString, I would reply that it allows
the distinction between a NULL value, that is an empty list of strings; and
a value which is an empty string. I do not know the real reason.
> 
> 
> Vince Marchetti
> 
> 
> 
>> On Apr 27, 2017, at 8:39 AM, Andreas Plesch <andreasplesch at gmail.com>
wrote:
>> 
>> On Wed, Apr 26, 2017 at 10:39 PM, Don Brutzman <brutzman at nps.edu> wrote:
>> On 4/26/2017 7:10 AM, Andreas Plesch wrote:
>> 
>> 
>> 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.
>> 
>> agreed 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.
>> agreed for SFString values.  Equivalent constructs:
>> 
>> XML
>>        <WorldInfo title='Hello world!'/> 
>>        <WorldInfo title="Hello world!"/>
>> 
>> Are you implying that  <WorldInfo title='Hello world!'/> should be a
conforming X3D XML encoding (of the WorldInfo node with a title field value)
?
>> I think you may since the X3D XML encoding does not get to define the
outer quotes of an attribute value, meaning that we are all pretty much on
the same page.
>> 
>> 
>> ClassicVRML and VRML encodings do not permit such variation, simply
>> 
>>        WorldInfo {
>>          title "Hello world!"
>>        }
>> 
>> 
>> Perhaps the X3D XML encoding spec. should retain a  paragraph on best
practices for consistency with the VRML encoding.
>> 
>> -Andreas
>> _______________________________________________
>> x3d-public mailing list
>> x3d-public at web3d.org
>> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
> 
> 
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org


_______________________________________________
x3d-public mailing list
x3d-public at web3d.org
http://web3d.org/mailman/listinfo/x3d-public_web3d.org




More information about the x3d-public mailing list