Menu

#39 attributes not allowed to have ' (single quote) in them.

closed
None
2016-11-26
2016-11-25
simon
No

this isn't allowed
<NavigationInfo type="'EXAMINE','ANY'"/>

while this is ok
<NavigationInfo type=""EXAMINE","ANY""/>

Discussion

  • Michalis Kamburelis

    Note: In the explanation below, I write the ampersand symbol as "A", not "&", to avoid it being interpreted by the SourceForge wiki-like syntax. So I write "Aquot;". Replace the "A" with actual ampersand symbol when actually trying out this stuff:)

    The fact that
    <NavigationInfo type="'EXAMINE','ANY'"/>
    is not allowed is correct, according to X3D specification, as far as I know.

    You can surround the single strings (EXAMINE or ANY) only with double quotes. This is following X3D specification. The double quote can be written as " or Aquot; inside the XML attribute (this is following the XML specification).

    You can surround the whole attribute by single or double quotes, ' or ". This is following the XML specification.

    Note that your 2nd example, the
    <NavigationInfo type="" EXAMINE","ANY""=""/>
    is also not correct. You have to encode double quote as Aquot; when you use " around the XML attribute.

    So the only valid versions are:
    - <NavigationInfo type=""EXAMINE","ANY""/>
    - <NavigationInfo type="Aquot;EXAMINEAquot;,Aquot;ANYAquot;"/>
    - <NavigationInfo type="Aquot;EXAMINEAquot;,Aquot;ANYAquot;"/>

    The relevant X3D XML specification is at: http://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/EncodingOfFields.html#SFString . Although the X3D spec wording is a little unfortunate, as it doesn't precisely specify all the possibilities, and it doesn't say which rules are set by the XML specification, and which which rules are set by the X3D spec. The idea that you can surround attributes with " or ' and you can quote things by Aquot; is from XML, and X3D specification doesn't really have a "saying" in this:)

    Is there any X3D viewer that allows the
    <NavigationInfo type="'EXAMINE','ANY'"/>
    construction? Then we can consider supporting it too, for compatibility.

     
  • Michalis Kamburelis

    • status: open --> pending
    • assigned_to: Michalis Kamburelis
     
  • simon

    simon - 2016-11-25

    yes, sorry to bother.

    my second example, the ok one, was meant to be; '"EXAMINE","ANY"'

    i have a xml generator that produces all double quoted attributes, and it seemed like x3d was forcing me to use singles just for this one attribute, seemed wrong, now i see to be able to use outer double quotes i need to replace thoughtout, which will also catch any slash escaping inside strings.

    even to properly use single quotes,(outermost) i need to replace in each string;

    ' -> &apos;

     

    Last edit: simon 2016-11-25
  • Michalis Kamburelis

    Remember to also replace literal & -> &amp; .

    In our engine, we also output X3D XML by a manual code (while we read XML using FPC DOM units, but writing was easier and faster to do manually). So you can see our code, in particular search for "StringToX3DXml" and "StringToX3DXmlMulti" inside https://github.com/castle-engine/castle-engine/blob/master/src/x3d/x3dlexer.pas .

    I understand that the issue is solved, closing:)

     
  • Michalis Kamburelis

    • status: pending --> closed
     
  • simon

    simon - 2016-11-26

    JFI looking for a text node example for some cut/paste coding

    http://x3dom.org/x3dom/example/x3dom_text.html
    ..

    <fontstyle family="'Times' 'Orbitron'" size="0.8"></fontstyle>

    ..
    which is not to spec, as you say

     

    Last edit: simon 2016-11-26
    • Michalis Kamburelis

      JFI looking for a text node example for some cut/paste coding
      http://x3dom.org/x3dom/example/x3dom_text.html
      ..
      <fontstyle family="'Times' 'Orbitron'" size="0.8"></fontstyle>

      Ouh. We should submit a bugreport to X3DOM then, to fix the invalid sample on http://x3dom.org/x3dom/example/x3dom_text.html . If you are willing to do it, it would be great.... feel free to refer them to this bugreport and to me:) I think you can report issues on http://www.x3dom.org/story/3/ .

      If you don't have time to report them this, I'll try to do it somewhere next week.

      If I'm mistaken and this is correct X3D, or if this is indeed incorrect X3D but it's commonly used (at least by X3DOM, which is popular), then we will implement it in CGE.

       
  • Michalis Kamburelis

    • status: closed --> open
     
  • Michalis Kamburelis

    I happened to be on Windows now, and created and tested this small testcase: https://github.com/castle-engine/demo-models/blob/master/x3d/test_single_quotes_mfstring.x3d

    Quick test shows that latest Instant Reality and BS Contact do not support the syntax

    field="'value1,'value2'"

    So the popular proprietary X3D players agree with my judgement: this is not correct X3D.

    Only X3DOM handles it.

    I guess that view3dscene can safely ignore this too. Althought it would be nicer if we produced a simple warning in this case, instead of refusing to read the faulty X3D file at all -- this is done now:)

    Closing.

     
  • Michalis Kamburelis

    • status: open --> closed
     
  • simon

    simon - 2016-11-26

    will report.

    the mfstring in the navigation node, in x3dom, doesn't like this, so its not consistent.

     

Log in to post a comment.