>Drinking the EMF Kool-Aid

Recently I ran into a problem that seemed perfect for EMF to solve. Typically, I’m not a model driven development person, but I need a model for an XPath expression after it is parsed. Various information needs to be tracked, and the annoyances with Xalan and JAXP finally drove me to go the custom route. It’s amazing how difficult it actually is to find an XPath 1.0 tokenizer that actually exposes the API for walking through the tokens of an XPath expression. I looked at a wide variety of grammars, and finally found a nice EPL compatible parser from the JXPath Apache Commons project. Xalan hid most of it’s goodies under protected or package level methods only. Making it utterly useless for using outside of Xalan for any other purpose than Xalan.

So, with JXPath as the tokenizer, this opened the door for finally getting to the pieces necessary to populate a model. The model is necessary to help provide some advance functionality for Content Assistance for the XSL Tooling project. In particular Hover Help, recognizing the return DataTypes, the allowable data types for a function’s arguments, how many arguments may it have, etc. However, I didn’t want to write all the necessary modeling code myself. It’s do able, but just not something I wanted to do.

So, with Ed Merks channeling Locutus of Borg, “Resistance is futile…”, I started drinking the EMF Kool-Aid.

I managed to get a fairly simple model working to hold the key pieces that I needed. A few stumbling blocks have occurred, mainly due to my own learning curve with EMF, but so far so good. The one thing I did find odd, is the ability to generate the Tests for the model. While this does provide a suite of tests to test the model, it doesn’t necessarily give you a good test suite.

Let me clarify this last statement. The assumption is that you modeled it correctly. However, if you forgot something in your model like a required field, or you have the name of the field wrong in the model, the test suite will be wrong as well.

Instead of opting for the test suite to be generated, I just generated the model code, and have been writing some basic tests myself to test the functionality and design. Using this method, I’ve been able to actual uncover several test failures because I had the model wrong. So far I have written no code in any of the core XSL plugins to use this model. Hopefully, taking this approach will save me from having to do any major rework due to having a to rework the model in the future because I forgot some functionality.

This entry was posted in eclipse, xml, xsl. Bookmark the permalink.

One Response to >Drinking the EMF Kool-Aid

  1. Ed Merks says:

    >David, it’s been a pleasure helping you get started. I particularly like helping people like you who I see being so helpful with their own community. Naturally being helpful always pays off, which has been the case here when you uncovered a tricky problem in the XSTL schema where mixed content had been restricted to be simple content.With regard to the generated tests, those tests are really intended just as scaffolding to get you started. I’m not sure it’s really possible to generate meaningful test cases from a model. If done correctly, all tests would just pass. I’ve not been a big fan of it for that very reason; our tests are all hand written scenarios…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s