[X3D-Public] Should MFString (and SFString) in XML encoding use backslashes?

Michalis Kamburelis michalis.kambi at gmail.com
Mon Jul 18 23:21:34 PDT 2011


Hi,

While testing new X3D XML output in view3dscene, I came across a
question with how to deal with double quotes that are part of "normal"
string content. Suppose you have MFString, with a single value

  Some "quotes"

Question is: should this be encoded in XML as

  field='"Some "quotes""'

or should we precede "real" double quotes with backslashes, like

  field='"Some \"quotes\""'

The 2nd form looks ugly (what, I have to use both XML entities and
backslashes?). But it's also more precise: XML DOM reading units may
assume that " inside attribute is exactly equal to ", and XML
readers may assume the same. For example, XML reading unit I currently
use replaces " (and other entities) with real characters, so for
the 1st form my program sees value

  "Some "quotes""

So it's ambiguous which double quotes delimit strings inside MFString,
and which are "real" double quotes inside content. 2nd form, with
backslashes, doesn't have this problem.

Looks like X3D XML spec isn't sure about this itself:

- Latest version,
http://www.web3d.org/x3d/specifications/ISO-IEC-19776-1.2-X3DEncodings-XML/Part01/EncodingOfFields.html#SFString
, shows example with

  <Text string='"He said, \"Immel did it!\""' />

Suggesting backslashes are needed. But it's just an example. No text in
SFString/MFString spec says explicitly to use backslashes.

- Older X3D XML spec shows the same example without backslahes:
http://www.web3d.org/x3d/specifications/OLD/ISO-IEC-19776-1-X3DEncodings-XML/Part01/EncodingOfFields.html#SFString
,

  <Text string='"He said, "Immel did it!""' />

If backslashes should indeed be used for double quotes in MFString,
there remain two questions:
- Should they be used for SFString too? This means reading SFString from
X3D XML isn't so trivial (you cannot just take attribute value). But
would be consistent.
- What about other values? For example, META content may contain double
quotes. Should they be preceded with backslashes also?

Michalis



More information about the X3D-Public mailing list