So would the idea be to create a compiler from Orderly to JSONSchema.
If so then all the features of Orderly must be a strict subset of
JSONSchema (I am not sure if it is or isn't, I am not well versed in
JSONSchema). I really like the Diet, and I am a supporter of easier to
read and write schema versus larger harder to maintain documents. I
joined this list to specifically mention this issue. I really hope
this picks up as I would love to write, use, and read Schema's using
Orderly.
--
Hatem Nassrat
I would suggest placing the maxima and minima for values after the type
rather than the name. That is, not:
integer age[,125];
But rather:
integer[,125] age;
This makes the syntax more consistent with you suggested syntax for
unions:
union {
integer[1900,2010];
string;
} born;
And require, or at least allow, the name to be quoted:
integer[,125] "age";
Because JSON keys may contain spaces.
Not sure about the square brackets to represent optional bits. How about
the question mark?
object {
string "name";
integer[,125] "age" ?;
array {
object {
string "street-address" ?;
string "location";
string "region" ?;
};
} "address" ?;
} "person";
--
Toby A Inkster
<mailto:ma...@tobyinkster.co.uk>
<http://tobyinkster.co.uk>
I would recommend against using indentation or linefeeds for semantic
information, or making separators optional.
-+ Tatu +-
The question mark I take from regular expressions, where it make the
previous subpattern match optional. Meta characters from regular
expressions include:
(foo|bar) = alternatives
foo? = optional
foo+ = one or more
foo* = zero or more
foo{2,6} = between two and six
foo{2,} = at least two
foo{,6} = at most six
Some of those concepts might be useful in schemas. Some of those
concepts you already cover.
if foo was an int, how would you say that they had acceptable values of 1-10
int foo[1,10]{,6}
Seems complex.
Also does Orderly cover non inclusive ranges like (1,10] or [1, 10)?
--
Hatem Nassrat
# A schema describing the data returned from the BrowserPlus services
# API at http://browserplus.yahoo.com/api/v3/corelets/osx
array {
object {
string name;
string versionString;
string os [ "ind", "osx", "win32" ];
integer size;
string documentation;
string CoreletType [ "standalone", "dependent", "provider" ];
# if CoreletType is "standalone" or "provider", then
# CoreletAPIVersion must be present
integer CoreletAPIVersion ?;
# if CoreletType is "dependent", then CoreletRequires must be present
object {
string Name;
string Version;
string Minversion;
} CoreletRequires ?;
};
};
I think the idea of keeping this a representation of JSON schema is good.
But one aspect not yet covered on this thread (I think?) is creation
of named types (subtypes), within schema definition itself.
It was mentioned in the comments section; and I think it's an area
where improvements would be very important for data binding use cases
(which is more common use case than validation for many XML users).
That is: ability to define reusable types; such that 'object' is only
used as the base class for reusable types, or maybe for one-off
"private" types.
So instead of repeating object (or array etc) definition, define type
once, use and reuse where needed.
This not only makes definition more compact (and I would argue
readable), but also allows code generation or binding tools to know
that instances are related types. This is not a problem for loosely
typed language (like js, ruby, perl), but is for more statically typed
(like Java etc); without explicit types, new dummy classes would need
to be created for each 'anonymous' object being encoutnered.
I know that JSON schema can do this, although I am not sure if that
always requires creation of separate schemas and direct linkage via
URLs. But even if it does, perhaps Orderly definition could generate
multiple separate JSON schema instances, act as sort of uber-schema,
if necessary.
-+ Tatu +-