Saturday, February 09, 2008

Mixed content in Glimmerized XML

In my last post about Glimmerized XML, I talked about one way of authoring mixed element text content. I also talked about two surprises that will make it easy to author mixed content. I'll go over one of them (the bigger one) in this post, which makes it super easy to create mixed content without jumping through hoops in the Ruby language.

Suppose you have an HTML snippet as follows:

<p>Glimmerized XML is such a <em>long</em> name! Maybe we should start calling it <strong>Glimmer XML</strong> instead.</p>

Without the surprise enhancement to Glimmer XML, here is how you would do it:

p {
  text "Glimmerized XML is such a "
  em { "long" }
  text " name! Maybe we should start calling it "
  strong { "Glimmer XML" }
  text "instead."
}

I think you would agree that authoring mixed content is the only weakness in authoring XML with a Ruby DSL. Well, not anymore!!! Check this out:

p { "Glimmerized XML is such a #em{long} name! Maybe we should start calling it #strong{Glimmer XML} instead." }

Magnificent, isn't it? You can embed tags directly within the double-quoted text instead of having to switch context and define the tags outside the text!

Stay tuned for the other surprise that will ease authoring mixed content with special XML characters.

p.s. Antoine, I responded to your earlier comments over here

1 comment:

Eric said...

Glimmerized XML? Yeah, it seems that after 10 frustrating years with XML people finally rediscover S-expressions again. Back to the roots...