Re: spaces in hdf keys?

Brandon Long <[email protected]> Tue, 12 Jan 2010 14:22:56 -0800
Newsgroups gmane.text.clearsilver.general
Organization Fiction L Networks
Message-ID <20100112222256.GA4386@bl1>
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/