Stuff in the pipeline for CurlyML.
This seems a natural way to go. Look at how much Hibernate version 3 has been simplified by the replacement of cumbersome XML mapping files with neat annotations right there in the Java source.
These things also are a lot simpler in a simple language like CurlyML. I don't know about you but I think XML DTDs and Schemas aren't the easiest things in the world to read.
I'm thinking that something like this might be a good way of expressing schemas...
person { name { $ } address { street { $ } city { $ } state { $ } zip { $ } } ?friends { *friend { name { $ } } } occupation { |{doctor engineer chef} } interest { |{ art{ |{ music photography painting } } cars{ |{racing collecting toy} } computers{ ?{ type { $ } } } } }
This says: A person is defined as having a name node, (containing a string), followed by an address node which is composed of nodes named street, city, state and zip, which all contain a single string. A person furthermore may or may not contain a single node named "friends", which may contain any number of nodes named "friend", which in turn must contain a string.
A person must contain an occupation node, which contains a choice of texts which could be doctor, engineer, or chef.
Lastly we have an interest node, which contains a choice of art, music, or computers. Art and music have a sub node themselves which is in turn a choice. The computers node contains an optional type node.
x y z | Ordered sequence |
$ | String |
?x | x is optional |
*x | x may be repeated 0 or more times |
+x | x is repeated 1 or more times |
x{ } | x is a parent node which may contain other nodes between the curlies |
|{x y z} | choice of one of x, y or z |