On Fri, May 11, 2012 at 10:11 AM, Eric Stob <
eric...@blekko.com> wrote:
[...]
>
> Is ID completely free form? Does it always start with pound sign? Contain dots or slashes? Should it include namespace? Company / project name?
>
That is actually a difficult question. The spec (draft v3) says:
----
This attribute defines the current URI of this schema (this attribute
is effectively a "self" link). This URI MAY be relative or absolute.
If the URI is relative it is resolved against the current URI of the
parent schema it is contained in. If this schema is not contained in
any parent schema, the current URI of the parent schema is held to be
the URI under which this schema was addressed. If id is missing, the
current URI of a schema is defined to be that of the parent schema.
The current URI of the schema is also used to construct relative
references such as for $ref.
----
This is not very clear, to say the least. In theory, id can be
anything, but some values just don't make any sense. Consider:
As a rule of thumb:
* limit yourself to hash values (ie, fragments as per the URI spec --
which mean they MUST be URI encoded should a reserved character be
present) for "id",
* EXCEPT for a "parent-less" schema, ie a root schema, where you
should, ideally, have an absolute URI (a non absolute URI doesn't make
any sense anyway at this particular position) WITHOUT a fragment part,
or an empty one (again, this doesn't make any sense and conflicts with
JSON Reference).
Also, you may use JSON Pointer to address subschemas. Example:
{
// whatever
"x": {
"id": "#myschema"
}
// whatever
}
If, within this schema, you want to address the subschema, you may
write a JSON Reference using either:
{
"$ref": "#myschema"
}
or (JSON Pointer):
{
"$ref": "#/x"
}
Also note that nothing in the spec forbids duplicate ID entries within
the same schema (which is a mistake imo). JSON Pointers, on the other
hand, are unambiguous, you have no two ways of referring a part of a
JSON instance.
That is only part of the story...
--
Francis Galiegue,
fgal...@gmail.com
"It seems obvious [...] that at least some 'business intelligence'
tools invest so much intelligence on the business side that they have
nothing left for generating SQL queries" (Stéphane Faroult, in "The
Art of SQL", ISBN 0-596-00894-5)