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

Vincent Marchetti vmarchetti at kshell.com
Thu Apr 27 06:26:01 PDT 2017


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




More information about the x3d-public mailing list