söndag, september 17, 2006

JvYAML and RbYAML - what's to come?

I know I've posted about the next release of JvYAML a few times, but going has gotten tough, since there are so many interesting projects to work at. Anyway, I was thinking that I would blog a bit again, since a significant new feature has reared it's head. It's about YAML 1.0 compatibility. This needs to be added to both JvYAML and RbYAML in fact. The reason is a recent incident where YAML communication between JRuby and Ruby broke in a slightly embarrassing way. Most of you probably know which incident I'm talking about.

The problem is very simple. YAML 1.1 is _almost_ backwards compatible to 1.0, with the exception for a few points. The point that broke is the shorthand tags from the YAML type repository. In YAML 1.0 you could prefix a value with !str and this means it shouldn't be interpolated as another type of value. A typical example (and actually the example that triggered the incident) is this:
version: !str 0.2
Now, in YAML 1.1, it doesn't look the same way. It was decided that a single exclamation point is actually shorthand for the user namespace, while a double exclamation point means the yaml.org:2002-namespace. So, the above example in YAML 1.1 is
version: !!str 0.2
This is a tiny change, but it breaks, since YAML 1.0 handles !!str as a private type, and YAML 1.1 handles !str as a private type. Not a really nice situation.

The solution in my case will be to add a flag for RbYAML and JvYAML that specifies that you want 1.0-compatibility. When that flag is turned on, some of these issues will be handled correctly by the parser, and emitted in a way an 1.0 parser could read. This will be the only change in RbYAML. But JvYAML will contain (as detailed before) an emitter, JavaBean materialization and many bug fixes.

Inga kommentarer: