Loading ...
Sorry, an error occurred while loading the content.

spaces in hdf keys?

Expand Messages
  • Scott Hassan
    Are spaces allowed in HDF key names? Scott -- import neo_cgi, neo_util h = neo_util.HDF() h.setValue( a b , 1 ) s = h.writeString() h2 = neo_util.HDF()
    Message 1 of 6 , Dec 4, 2009
    View Source
    • 0 Attachment
      Are spaces allowed in HDF key names?

      Scott
      --

      import neo_cgi, neo_util

      h = neo_util.HDF()
      h.setValue("a b", "1")
      s = h.writeString()

      h2 = neo_util.HDF()
      h.readString(s)
    • Nikolai Kondrashov
      ... What you set in C is almost never checked. However, there are pretty strict rules when reading HDF from files (see _hdf_read_string: isalnum(*s) || *s ==
      Message 2 of 6 , Dec 4, 2009
      View Source
      • 0 Attachment
        Scott Hassan wrote:
        > Are spaces allowed in HDF key names?
        What you set in C is almost never checked. However, there are pretty strict
        rules when reading HDF from files (see _hdf_read_string: isalnum(*s) || *s == '_'),
        and a bit less strict rules when referring from a template.
        See cs/csparse.cs - can't point the place, but it certainly cannot contain
        tokens and whitespace.

        Sincerely,
        Nick
      • David Jeske
        I know this question is super old, but I didn t see it answered. Yes, HDF keys can contain spaces, but obviously this creates problems for using typical
        Message 3 of 6 , Jan 12, 2010
        View Source
        • 0 Attachment
          I know this question is super old, but I didn't see it answered.

          Yes, HDF keys can contain spaces, but obviously this creates problems for using
          typical "dotted path" syntax in CS files. Furthermore, I don't believe there is
          any way to reference a top-level node that has a space in it from CS. brandon
          can elaborate.




          -- Scott Hassan wrote:
          >
          > Are spaces allowed in HDF key names?
          >
          > Scott
          > --
          >
          > import neo_cgi, neo_util
          >
          > h = neo_util.HDF()
          > h.setValue("a b", "1")
          > s = h.writeString()
          >
          > h2 = neo_util.HDF()
          > h.readString(s)
          >
          >
          > ------------------------------------
          >
          > Yahoo! Groups Links
          >
          >
          >
        • Scott Hassan
          ... using ... is ... Shouldn t writeString() quote the keys such that readString can read the HDF properly? Scott
          Message 4 of 6 , Jan 12, 2010
          View Source
          • 0 Attachment
            -- David Jeske wrote:
            > I know this question is super old, but I didn't see it answered.
            >
            > Yes, HDF keys can contain spaces, but obviously this creates problems for
            using
            > typical "dotted path" syntax in CS files. Furthermore, I don't believe there
            is
            > any way to reference a top-level node that has a space in it from CS. brandon
            > can elaborate.

            Shouldn't writeString() quote the keys such that readString can read the HDF
            properly?

            Scott
          • Brandon Long
            ... So... As David points out, there is no validation on HDF keys when calling the C API to add them to a dataset. So, the only character that s meaningful in
            Message 5 of 6 , Jan 12, 2010
            View Source
            • 0 Attachment
              On 01/12/10 Scott Hassan uttered the following other thing:
              > -- David Jeske wrote:
              > > I know this question is super old, but I didn't see it answered.
              > >
              > > Yes, HDF keys can contain spaces, but obviously this creates
              > > problems for using typical "dotted path" syntax in CS files.
              > > Furthermore, I don't believe there is any way to reference a
              > > top-level node that has a space in it from CS. brandon can
              > > elaborate.
              >
              > Shouldn't writeString() quote the keys such that readString can read
              > the HDF properly?

              So...

              As David points out, there is no validation on HDF keys when calling the
              C API to add them to a dataset. So, the only character that's
              meaningful in a key is the dot between levels in the hierarchy. People
              have asked for validation before, but I haven't done it because of the
              performance hit and because it would break compatibility.

              There is validation when reading HDF from a string or disk, and
              the CS parser also has limits. There's a fake-BNF for CS in the cs.h
              file and one for HDF in the neo_hdf.h file, both updated to be more
              complete in the head of tree:

              http://code.google.com/p/clearsilver/source/browse/trunk/util/neo_hdf.h
              http://code.google.com/p/clearsilver/source/browse/trunk/cs/cs.h

              These were updated so that they would be consistent with our internal
              pure Java version, JSilver (hopefully to be open sourced at some point).

              Having write string/hdf do proper escaping would require a change to the
              syntax to create an escape mechanism, which requires at least creating
              an escape character out of something that was a valid character before.
              Since the HDF syntax doesn't allow any punctuation besides dot, that
              could probably be arranged if it was useful.

              Brandon
              --
              "Here's a nickel, kid. Get yourself a better computer."
              -"Dilbert" by Scott Adams 6-24-95
              http://www.fiction.net/blong/
            • Nikolai Kondrashov
              ... The validation could be added for debug build only, which will be useful for most cases. Although, ClearSilver doesn t have a debug build, AFAIK. ... Last
              Message 6 of 6 , Jan 12, 2010
              View Source
              • 0 Attachment
                Brandon Long wrote:
                > As David points out, there is no validation on HDF keys when calling the
                > C API to add them to a dataset. So, the only character that's
                > meaningful in a key is the dot between levels in the hierarchy. People
                > have asked for validation before, but I haven't done it because of the
                > performance hit and because it would break compatibility.
                The validation could be added for debug build only, which will be useful for
                most cases. Although, ClearSilver doesn't have a debug build, AFAIK.

                > Having write string/hdf do proper escaping would require a change to the
                > syntax to create an escape mechanism, which requires at least creating
                > an escape character out of something that was a valid character before.
                > Since the HDF syntax doesn't allow any punctuation besides dot, that
                > could probably be arranged if it was useful.
                Last time I checked across all the places which are dealing with the HDF
                names, there were no characters to spare. I think it's HDF file reader,
                which limits HDF names to [0-9a-zA-Z_.]. Yeah it says it right there in the
                _hdf_read_string:

                /* Valid hdf name is [0-9a-zA-Z_.]+ */
                name = s;
                while (*s && (isalnum(*s) || *s == '_' || *s == '.')) s++;

                So, personally, I'm using '_' character to escape the names explicitly, when
                needed.

                However, a character outside this set could be used, but it would make the
                datasets unreadable by any old code.

                Sincerely,
                Nick
              Your message has been successfully submitted and would be delivered to recipients shortly.