<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1063388560461943251</id><updated>2012-01-10T14:42:08.043-08:00</updated><category term='dsl'/><category term='xtext'/><category term='xml'/><category term='demo'/><title type='text'>antonywilkins</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://antonywilkins.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1063388560461943251/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://antonywilkins.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Antony Wilkins</name><uri>http://www.blogger.com/profile/13733916640946257048</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1063388560461943251.post-1276705912667909839</id><published>2009-08-06T17:43:00.001-07:00</published><updated>2009-08-06T17:55:14.016-07:00</updated><title type='text'>Xtext Spring Demo - Part 5</title><content type='html'>&lt;h2&gt;Serialisation of model to text form&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;What about if you already have instances of the Java model classes - and want to save them in text form - using your new language.&lt;br /&gt;&lt;br /&gt;This is also very simple.&lt;br /&gt;&lt;br /&gt;Coming soon...&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-4.html"&gt;Previous&lt;/a&gt;&amp;nbsp;&lt;a href="http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo.html"&gt;Start&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1063388560461943251-1276705912667909839?l=antonywilkins.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antonywilkins.blogspot.com/feeds/1276705912667909839/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-5.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1063388560461943251/posts/default/1276705912667909839'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1063388560461943251/posts/default/1276705912667909839'/><link rel='alternate' type='text/html' href='http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-5.html' title='Xtext Spring Demo - Part 5'/><author><name>Antony Wilkins</name><uri>http://www.blogger.com/profile/13733916640946257048</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1063388560461943251.post-2479968809209925143</id><published>2009-08-06T17:41:00.003-07:00</published><updated>2009-08-08T08:26:07.953-07:00</updated><title type='text'>Xtext Spring Demo - Part 4</title><content type='html'>&lt;h2&gt;Export Spring XML from model&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;In the previous parts we saw how to integrate our Spring model at runtime.&lt;br /&gt;&lt;br /&gt;But suppose we want to actually generate something from our model during development or build?&lt;br /&gt;&lt;br /&gt;Xtext models can be used in combination with another language - Xpand - to generate code or other text.&lt;br /&gt;&lt;br /&gt;As an example of this, we will write a simple code generator for our Spring model - one that can export our model as valid Spring XML.&lt;br /&gt;&lt;br /&gt;The generator project has an example code generator - open the existing file &lt;code&gt;src/templates/Template.xpt&lt;/code&gt;, and replace it's example text with the following:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;«IMPORT spring»&lt;br /&gt;&lt;br /&gt;«EXTENSION templates::Extensions»&lt;br /&gt;&lt;br /&gt;«DEFINE main FOR SpringModel-»&lt;br /&gt;«FILE "spring-confg.xml"-»&lt;br /&gt;&amp;lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"&lt;br /&gt;                  "http://www.springframework.org/dtd/spring-beans.dtd"&amp;gt;&lt;br /&gt;&amp;lt;beans&amp;gt;&lt;br /&gt;«EXPAND bean FOREACH beans.sortBy(e|e.name)-»&lt;br /&gt;&amp;lt;/beans&amp;gt;&lt;br /&gt;«ENDFILE-»&lt;br /&gt;«ENDDEFINE»&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;«DEFINE bean FOR Bean-»&lt;br /&gt;    &amp;lt;bean id="«name»" class="«type»"«IF properties.size &amp;gt; 0»&amp;gt;&lt;br /&gt;«ELSE-»/&amp;gt;&lt;br /&gt;«ENDIF-»&lt;br /&gt;«EXPAND property FOREACH properties.sortBy(e|e.name)-»&lt;br /&gt;«IF properties.size &amp;gt; 0 »    &amp;lt;/bean&amp;gt;&lt;br /&gt;«ENDIF»&lt;br /&gt;«ENDDEFINE»&lt;br /&gt;&lt;br /&gt;«DEFINE property FOR Property-»&lt;br /&gt;        &amp;lt;property name="«name»" «IF value!=null-»value="«value»"«ENDIF-»«IF ref!=null-»ref="«ref.name»"«ENDIF-» /&amp;gt;&lt;br /&gt;«ENDDEFINE»&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_WyPfbFs0hrs/Snt8iLL2dhI/AAAAAAAAAAM/Yt5-FrdKP4U/s1600-h/xpand_template.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 297px;" src="http://4.bp.blogspot.com/_WyPfbFs0hrs/Snt8iLL2dhI/AAAAAAAAAAM/Yt5-FrdKP4U/s400/xpand_template.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5367020307501970962" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now right click on src/workflow/SpringGenerator.mwe and Run As-&gt;MWE Workflow.  The console should show successful looking logging text, and the code generator will have created a file from our model.  Open src-gen/spring-config.xml to see the results:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_WyPfbFs0hrs/Snt8yGJkznI/AAAAAAAAAAU/hSN7yBoYUy8/s1600-h/generated_spring_xml.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 297px;" src="http://2.bp.blogspot.com/_WyPfbFs0hrs/Snt8yGJkznI/AAAAAAAAAAU/hSN7yBoYUy8/s400/generated_spring_xml.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5367020581028154994" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-3.html"&gt;Previous&lt;/a&gt;&amp;nbsp;&lt;a href="http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-5.html"&gt;Next&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1063388560461943251-2479968809209925143?l=antonywilkins.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antonywilkins.blogspot.com/feeds/2479968809209925143/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-4.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1063388560461943251/posts/default/2479968809209925143'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1063388560461943251/posts/default/2479968809209925143'/><link rel='alternate' type='text/html' href='http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-4.html' title='Xtext Spring Demo - Part 4'/><author><name>Antony Wilkins</name><uri>http://www.blogger.com/profile/13733916640946257048</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_WyPfbFs0hrs/Snt8iLL2dhI/AAAAAAAAAAM/Yt5-FrdKP4U/s72-c/xpand_template.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1063388560461943251.post-3141481594318317252</id><published>2009-08-06T17:41:00.001-07:00</published><updated>2009-08-08T08:13:58.627-07:00</updated><title type='text'>Xtext Spring Demo - Part 3</title><content type='html'>&lt;h2&gt;Read a Spring model to load a BeanFactory&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;As a hint on how you could extend Spring to create a new BeanFactory loader, this example shows how to populate a BeanFactory from the model files.&lt;br /&gt;&lt;br /&gt;This is very similar to how the Spring implementation will populate a BeanFactory while parsing in, for example, ClassPathXmlApplicationContext.&lt;br /&gt;&lt;br /&gt;The example only covers the basics, but Spring spend a lot more code doing even the equivalent slice of functionality in their BeanFactory loading code.&lt;br /&gt;&lt;br /&gt;In order to actually load a bean factory from the example file - we need to create the two example Java classes.  Their implementation is obvious and trivial, but for convenience you should download them and copy them into the generator project "src" folder from &lt;a href="https://eclipsecoding.svn.sourceforge.net/svnroot/eclipsecoding/trunk/dsl_demo/spring_demo/org.xtext.example.dsl.spring.generator/src/org/xtext/example/dsl/spring/generator/test"&gt;this location&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Create a new Java class like this example - within the generator project - org.xtext.example.dsl.spring.generator:&lt;br /&gt;&lt;code&gt;src/org/xtext/example/dsl/spring/integration/SpringIntegrationTest.java&lt;/code&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;package org.xtext.example.dsl.spring.integration;&lt;br /&gt;&lt;br /&gt;import org.eclipse.emf.common.util.URI;&lt;br /&gt;import org.eclipse.emf.ecore.resource.Resource;&lt;br /&gt;import org.eclipse.emf.ecore.resource.ResourceSet;&lt;br /&gt;import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;&lt;br /&gt;import org.springframework.beans.MutablePropertyValues;&lt;br /&gt;import org.springframework.beans.factory.config.BeanDefinitionHolder;&lt;br /&gt;import org.springframework.beans.factory.config.RuntimeBeanReference;&lt;br /&gt;import org.springframework.beans.factory.config.TypedStringValue;&lt;br /&gt;import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;&lt;br /&gt;import org.springframework.beans.factory.support.DefaultListableBeanFactory;&lt;br /&gt;import org.springframework.beans.factory.support.GenericBeanDefinition;&lt;br /&gt;import org.xtext.example.dsl.spring.SpringStandaloneSetup;&lt;br /&gt;import org.xtext.example.dsl.spring.spring.Bean;&lt;br /&gt;import org.xtext.example.dsl.spring.spring.Property;&lt;br /&gt;import org.xtext.example.dsl.spring.spring.SpringModel;&lt;br /&gt;&lt;br /&gt;public class SpringIntegrationTest {&lt;br /&gt;&lt;br /&gt; static {&lt;br /&gt;  SpringStandaloneSetup.doSetup();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; /**&lt;br /&gt;  * @param args&lt;br /&gt;  */&lt;br /&gt; public static void main(String[] args) {&lt;br /&gt;  SpringModel model = readSpringModel("src/model/MyModel.spring");&lt;br /&gt;&lt;br /&gt;  // Load a bean factory from the model&lt;br /&gt;  DefaultListableBeanFactory registry = new DefaultListableBeanFactory();&lt;br /&gt;  for (Bean bean : model.getBeans()) {&lt;br /&gt;   GenericBeanDefinition beanDef = new GenericBeanDefinition();&lt;br /&gt;   beanDef.setBeanClassName(bean.getType());&lt;br /&gt;   MutablePropertyValues propertyValues = new MutablePropertyValues();&lt;br /&gt;   for (Property property : bean.getProperties()) {&lt;br /&gt;    Object propertyValue = getPropertyValue(property);&lt;br /&gt;    propertyValues.addPropertyValue(property.getName(),&lt;br /&gt;      propertyValue);&lt;br /&gt;   }&lt;br /&gt;   beanDef.setPropertyValues(propertyValues);&lt;br /&gt;   BeanDefinitionHolder beanHolder = new BeanDefinitionHolder(beanDef, bean.getName());&lt;br /&gt;   BeanDefinitionReaderUtils.registerBeanDefinition(beanHolder, registry);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  Object bean = registry.getBean("myObject");&lt;br /&gt;  System.out.println(bean.getClass());&lt;br /&gt;  System.out.println(bean);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; private static Object getPropertyValue(Property property) {&lt;br /&gt;  Bean referencedBean = property.getRef();&lt;br /&gt;  if (referencedBean != null) {&lt;br /&gt;   return new RuntimeBeanReference(referencedBean.getName());&lt;br /&gt;  }&lt;br /&gt;  return new TypedStringValue(property.getValue());&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; private static SpringModel readSpringModel(String filename) {&lt;br /&gt;  Resource resource = loadModelResource(filename);&lt;br /&gt;  SpringModel model = (SpringModel) resource.getContents().get(0);&lt;br /&gt;  return model;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; /*&lt;br /&gt;  * this method, and the static initialiser call to&lt;br /&gt;  * SpringStandaloneSetup.doSetup() are all that are needed to load a model&lt;br /&gt;  * file&lt;br /&gt;  */&lt;br /&gt; private static Resource loadModelResource(String modelFile) {&lt;br /&gt;  ResourceSet resourceSet = new ResourceSetImpl();&lt;br /&gt;  URI uri = URI.createFileURI(modelFile);&lt;br /&gt;  Resource resource = resourceSet.getResource(uri, true);&lt;br /&gt;  return resource;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Right-click on the new class and Run As-&gt;Java Application.&lt;br /&gt;You should see the System.out.println calls output a bean retrieved from the BeanFactory into the console:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_WyPfbFs0hrs/Snt9wt7yoTI/AAAAAAAAAAc/cHXZVrzhU8U/s1600-h/integration_test_load_beanfactory.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 297px;" src="http://2.bp.blogspot.com/_WyPfbFs0hrs/Snt9wt7yoTI/AAAAAAAAAAc/cHXZVrzhU8U/s400/integration_test_load_beanfactory.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5367021656859648306" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-2.html"&gt;Previous&lt;/a&gt;&amp;nbsp;&lt;a href="http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-4.html"&gt;Next&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1063388560461943251-3141481594318317252?l=antonywilkins.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antonywilkins.blogspot.com/feeds/3141481594318317252/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-3.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1063388560461943251/posts/default/3141481594318317252'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1063388560461943251/posts/default/3141481594318317252'/><link rel='alternate' type='text/html' href='http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-3.html' title='Xtext Spring Demo - Part 3'/><author><name>Antony Wilkins</name><uri>http://www.blogger.com/profile/13733916640946257048</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_WyPfbFs0hrs/Snt9wt7yoTI/AAAAAAAAAAc/cHXZVrzhU8U/s72-c/integration_test_load_beanfactory.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1063388560461943251.post-6496523078449823833</id><published>2009-08-06T17:40:00.002-07:00</published><updated>2009-08-08T08:10:31.128-07:00</updated><title type='text'>Xtext Spring Demo - Part 2</title><content type='html'>&lt;h2&gt;Test our new language - standalone&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;The generated language Java implementation includes a parser and a set of Java model classes.&lt;br /&gt;&lt;br /&gt;The parser reads the model file text, and transforms into instances of the Java model classes.&lt;br /&gt;&lt;br /&gt;It's very simple to access these APIs.&lt;br /&gt;&lt;br /&gt;Create a new Java class like this example - within the generator project - org.xtext.example.dsl.spring.generator:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;src/org/xtext/example/dsl/spring/integration/ReadSpringModelTest.java&lt;/code&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;package org.xtext.example.dsl.spring.integration;&lt;br /&gt;&lt;br /&gt;import org.eclipse.emf.common.util.URI;&lt;br /&gt;import org.eclipse.emf.ecore.resource.Resource;&lt;br /&gt;import org.eclipse.emf.ecore.resource.ResourceSet;&lt;br /&gt;import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;&lt;br /&gt;import org.xtext.example.dsl.spring.SpringStandaloneSetup;&lt;br /&gt;import org.xtext.example.dsl.spring.spring.Bean;&lt;br /&gt;import org.xtext.example.dsl.spring.spring.Property;&lt;br /&gt;import org.xtext.example.dsl.spring.spring.SpringModel;&lt;br /&gt;&lt;br /&gt;public class ReadSpringModelTest {&lt;br /&gt;&lt;br /&gt; static {&lt;br /&gt;  SpringStandaloneSetup.doSetup();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; /**&lt;br /&gt;  * @param args&lt;br /&gt;  */&lt;br /&gt; public static void main(String[] args) {&lt;br /&gt;  // integration with generated language within loadModelResource&lt;br /&gt;  Resource resource = loadModelResource("src/model/MyModel.spring");&lt;br /&gt;&lt;br /&gt;  // extract the SpringModel from the resource - in our case there will be only one&lt;br /&gt;  SpringModel model = (SpringModel) resource.getContents().get(0);&lt;br /&gt;&lt;br /&gt;  // example usage - walk the model, printing the values&lt;br /&gt;  for (Bean bean : model.getBeans()) {&lt;br /&gt;   System.out.println("\n\nBean: " + bean.getName());&lt;br /&gt;   for (Property property : bean.getProperties()) {&lt;br /&gt;    System.out.println("\t" + property.getName() + ": "&lt;br /&gt;      + toValueString(property));&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; /*&lt;br /&gt;  * this method, and the static initialiser call to&lt;br /&gt;  * SpringStandaloneSetup.doSetup() are all that are needed to load a model&lt;br /&gt;  * file&lt;br /&gt;  */&lt;br /&gt; private static Resource loadModelResource(String modelFile) {&lt;br /&gt;  ResourceSet resourceSet = new ResourceSetImpl();&lt;br /&gt;  URI uri = URI.createFileURI(modelFile);&lt;br /&gt;  Resource resource = resourceSet.getResource(uri, true);&lt;br /&gt;  return resource;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; private static String toValueString(Property property) {&lt;br /&gt;  Bean referencedBean = property.getRef();&lt;br /&gt;  if (referencedBean != null) {&lt;br /&gt;   return " =&gt; " + referencedBean.getName();&lt;br /&gt;  }&lt;br /&gt;  String value = property.getValue();&lt;br /&gt;  if (value == null) {&lt;br /&gt;   return "«null»";&lt;br /&gt;  }&lt;br /&gt;  return "\"" + value + "\"";&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Right-click on the new class and Run As-&gt;Java Application.  You should see the System.out.println calls output into the console:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_WyPfbFs0hrs/Snt9-W9alDI/AAAAAAAAAAk/uZ7rjh8iJAA/s1600-h/integration_test_read_model.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 272px;" src="http://1.bp.blogspot.com/_WyPfbFs0hrs/Snt9-W9alDI/AAAAAAAAAAk/uZ7rjh8iJAA/s400/integration_test_read_model.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5367021891210613810" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-1.html"&gt;Previous&lt;/a&gt;&amp;nbsp;&lt;a href="http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-3.html"&gt;Next&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1063388560461943251-6496523078449823833?l=antonywilkins.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antonywilkins.blogspot.com/feeds/6496523078449823833/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1063388560461943251/posts/default/6496523078449823833'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1063388560461943251/posts/default/6496523078449823833'/><link rel='alternate' type='text/html' href='http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-2.html' title='Xtext Spring Demo - Part 2'/><author><name>Antony Wilkins</name><uri>http://www.blogger.com/profile/13733916640946257048</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_WyPfbFs0hrs/Snt9-W9alDI/AAAAAAAAAAk/uZ7rjh8iJAA/s72-c/integration_test_read_model.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1063388560461943251.post-1427121557724589780</id><published>2009-08-06T17:40:00.001-07:00</published><updated>2009-08-08T08:06:27.205-07:00</updated><title type='text'>Xtext Spring Demo - Part 1</title><content type='html'>&lt;h2&gt;Create a new language to define Spring Beans&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;Let's start by downloading and installing Xtext.&lt;br /&gt;&lt;br /&gt;Xtext is a set of plugins for &lt;a href="http://eclipse.org"&gt;Eclipse&lt;/a&gt; and can be obtained &lt;a href="http://xtext.org"&gt;here&lt;/a&gt; in a variety of formats.&lt;br /&gt;&lt;br /&gt;I recommend downloading the full distribution, because it includes links to the update site, and the integrated ANTLR parser bindings. This can be found &lt;a href="http://xtext.itemis.com/"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Once installed - start the Xtext Eclipse installation in a new workspace - and we can start creating our new parser.&lt;br /&gt;&lt;br /&gt;For this demonstration, I chose to create an alternative to the Spring XML bean definition language.&lt;br /&gt;&lt;br /&gt;This isn't because I think the end result is particularly useful - but it does offer a great test case for a simple language and a variety of integration scenarios.&lt;br /&gt;&lt;br /&gt;The demonstration stops some way short of being a fully-fledged replacement for Spring XML - it lacks support for most of Spring's features.&lt;br /&gt;&lt;br /&gt;It does hint at how to go this far, though - it would be interesting to see how little code is required to replace Spring's XML bean definition loader :)&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Create a new Xtext project&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;Create a new Xtext project by selecting the File menu, then New-&gt;Project... and choose "Xtext Project":&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_WyPfbFs0hrs/Snt-V3DJcmI/AAAAAAAAAAs/ldSp6tc0ABE/s1600-h/new_xtext_project.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 400px;" src="http://2.bp.blogspot.com/_WyPfbFs0hrs/Snt-V3DJcmI/AAAAAAAAAAs/ldSp6tc0ABE/s400/new_xtext_project.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5367022294961582690" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Give the project a name - use these examples:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Main project name: org.xtext.example.dsl.spring&lt;br /&gt;Language name: org.xtext.example.dsl.spring.Spring&lt;br /&gt;DSL-File extension: spring&lt;br /&gt;Create generator project: yes&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_WyPfbFs0hrs/Snt-jUHYyFI/AAAAAAAAAA0/pIcZ2GYdJiM/s1600-h/new_xtext_project2.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 400px;" src="http://3.bp.blogspot.com/_WyPfbFs0hrs/Snt-jUHYyFI/AAAAAAAAAA0/pIcZ2GYdJiM/s400/new_xtext_project2.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5367022526102292562" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;A set of projects are created - find the Spring.xtext file as shown and open it:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_WyPfbFs0hrs/Snt-j0twDsI/AAAAAAAAAA8/6X1943Pyjf4/s1600-h/new_xtext_project_open.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 264px;" src="http://1.bp.blogspot.com/_WyPfbFs0hrs/Snt-j0twDsI/AAAAAAAAAA8/6X1943Pyjf4/s400/new_xtext_project_open.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5367022534853136066" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As you see - a new Xtext project starts with an example language - an entity description language.&lt;br /&gt;(The Xtext language description language is actually very closely related to &lt;a href="http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form"&gt;EBNF&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;The example is no use to us now, so let's replace that text with our Spring Bean definition language definition.&lt;br /&gt;&lt;br /&gt;Leave the &lt;code&gt;grammar&lt;/code&gt; and &lt;code&gt;generate&lt;/code&gt; statements as they are, but replace the rest with:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;SpringModel:&lt;br /&gt; (beans+=Bean)*;&lt;br /&gt;&lt;br /&gt;Bean:&lt;br /&gt; 'bean' name=ID type=STRING&lt;br /&gt;   (properties+=Property)* ';';&lt;br /&gt;&lt;br /&gt;Property:&lt;br /&gt; name=ID '=' (ref=[Bean]|value=STRING);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_WyPfbFs0hrs/Sn2QX5stByI/AAAAAAAAAB8/kEi9MmENFZQ/s1600-h/new_xtext_grammar.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 265px;" src="http://4.bp.blogspot.com/_WyPfbFs0hrs/Sn2QX5stByI/AAAAAAAAAB8/kEi9MmENFZQ/s400/new_xtext_grammar.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5367605071195211554" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now - we generate the Java implementation code for our language - run the GenerateSpring.mwe file - right-click on it and Run As-&gt;MWE Workflow:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_WyPfbFs0hrs/Sn2RB0IEvgI/AAAAAAAAACE/_-g2qpOpIx8/s1600-h/generate_grammar.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 367px;" src="http://3.bp.blogspot.com/_WyPfbFs0hrs/Sn2RB0IEvgI/AAAAAAAAACE/_-g2qpOpIx8/s400/generate_grammar.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5367605791253904898" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The generator should run and you should see some successful looking output in the console:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_WyPfbFs0hrs/Sn2TyBuQn6I/AAAAAAAAACM/NMH2pBKyHdo/s1600-h/generated_grammar.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 265px;" src="http://4.bp.blogspot.com/_WyPfbFs0hrs/Sn2TyBuQn6I/AAAAAAAAACM/NMH2pBKyHdo/s400/generated_grammar.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5367608818560704418" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Great!  Let's test our new language :):&lt;br /&gt;&lt;br /&gt;We don't need to write any Java to start with - we can test our parser with the free IDE editor generated in the last step.&lt;br /&gt;&lt;br /&gt;Normally one would export the generated plugins and restart a copy of eclipse with these plugins loaded, but to quickly test our language - we can just launch a test instance of eclipse to do that:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_WyPfbFs0hrs/Sn2UWWs3eSI/AAAAAAAAACU/B2Ipy5f7yWs/s1600-h/launch_test_eclipse.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 373px; height: 400px;" src="http://4.bp.blogspot.com/_WyPfbFs0hrs/Sn2UWWs3eSI/AAAAAAAAACU/B2Ipy5f7yWs/s400/launch_test_eclipse.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5367609442667297058" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Import the "generator" project (org.xtext.example.dsl.spring.generator if you used the example names) into the test workspace, and open src/model/MyModel.spring.&lt;br /&gt;&lt;br /&gt;As before - this file is pre-populated with an example model (a valid example of the original Entity language we blew away, but invalid for our new language).&lt;br /&gt;&lt;br /&gt;Therefore - the editor quite correctly highlights an error:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_WyPfbFs0hrs/Snt--8HmY9I/AAAAAAAAABk/50Guuvk50Tk/s1600-h/test_eclipse_new_model_example_in_error.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 287px;" src="http://3.bp.blogspot.com/_WyPfbFs0hrs/Snt--8HmY9I/AAAAAAAAABk/50Guuvk50Tk/s400/test_eclipse_new_model_example_in_error.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5367023000697070546" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;So - paste this valid Spring bean model into the file - replacing all the current text:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;/*&lt;br /&gt; * This is an example model&lt;br /&gt; */&lt;br /&gt;bean myObject "org.xtext.example.dsl.spring.generator.test.MyType"&lt;br /&gt; intAttribute = "5"&lt;br /&gt; stringAttribute = "xtext is easy..."&lt;br /&gt; otherAttribute = otherObject;&lt;br /&gt;&lt;br /&gt;bean otherObject "org.xtext.example.dsl.spring.generator.test.OtherType"&lt;br /&gt; someOtherAttribute = "...when you know how";&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You should see the syntax highlighting in effect immediately, and notice that Java-like comments are supported:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_WyPfbFs0hrs/Snt_eJDHL4I/AAAAAAAAABs/F1avtBUOBKk/s1600-h/test_eclipse_new_model_text.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 287px;" src="http://1.bp.blogspot.com/_WyPfbFs0hrs/Snt_eJDHL4I/AAAAAAAAABs/F1avtBUOBKk/s400/test_eclipse_new_model_text.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5367023536743853954" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Content assist proposals are given on Ctrl-Space - for syntax and for references and property values.&lt;br /&gt;These can be customised.&lt;br /&gt;Later we will see how to add Java class names proposals to the Bean "type" property...&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_WyPfbFs0hrs/Snt_ebXMK_I/AAAAAAAAAB0/lFHuGvTLTFw/s1600-h/content_assist.JPG"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 287px;" src="http://3.bp.blogspot.com/_WyPfbFs0hrs/Snt_ebXMK_I/AAAAAAAAAB0/lFHuGvTLTFw/s400/content_assist.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5367023541659905010" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Hit Ctrl+Shift+F.&lt;br /&gt;&lt;br /&gt;Okay - sorry! It puts all the text on to one unreadable line.&lt;br /&gt;&lt;br /&gt;That part isn't free - to get pretty printing we have to do a little Java coding.&lt;br /&gt;&lt;br /&gt;We'll get to that later so hit Ctrl-Z for now and we'll write a test harness to demonstrate how you'd integrate the generated parser into your code.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo.html"&gt;Previous&lt;/a&gt;&amp;nbsp;&lt;a href="http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-2.html"&gt;Next&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1063388560461943251-1427121557724589780?l=antonywilkins.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antonywilkins.blogspot.com/feeds/1427121557724589780/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1063388560461943251/posts/default/1427121557724589780'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1063388560461943251/posts/default/1427121557724589780'/><link rel='alternate' type='text/html' href='http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-1.html' title='Xtext Spring Demo - Part 1'/><author><name>Antony Wilkins</name><uri>http://www.blogger.com/profile/13733916640946257048</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_WyPfbFs0hrs/Snt-V3DJcmI/AAAAAAAAAAs/ldSp6tc0ABE/s72-c/new_xtext_project.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1063388560461943251.post-4755966475563122385</id><published>2009-08-06T17:37:00.000-07:00</published><updated>2009-08-08T08:18:11.696-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='xtext'/><category scheme='http://www.blogger.com/atom/ns#' term='dsl'/><title type='text'>Why Not XML?</title><content type='html'>&lt;h1&gt;What's wrong with XML?&lt;/h1&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;...and why is it so popular?&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;Is it popular?  It's certainly not in short supply. It does seem like you can't open any Java project without encountering XML files, and regardless of how cutting-edge the technology used there - it always seems to bring on some new XML file format.&lt;br /&gt;&lt;br /&gt;It does seem popular with framework providers.&lt;br /&gt;&lt;br /&gt;But it doesn't seem popular with application builders using the frameworks - if you listen to the rhetoric.  Until they have to write a custom config file or interchange file, of course.  Then it seems like just the thing.  If you listen to the users who have to read and write these config files, though...&lt;br /&gt;&lt;br /&gt;In short - XML is a free (crap) parser and serializer/formatter.  Which is slightly better for a programmer than no free parser/formatter at all.  Programmatic access to XML is very well supported these days and a new config file format can often be supported in minutes by an experienced SAX/DOM/JAXB/whatever programmer.&lt;br /&gt;&lt;br /&gt;Which is all bad for the end user because whenever a new file format is needed XML is automatically chosen as the base format.&lt;br /&gt;&lt;br /&gt;But writing custom languages without XML is hard, right?  I mean - there's ANTLR, but that's complex to learn and hard to get tool support for.  Writing a new language in raw antlr is not a task to be done in minutes by a SAX/DOM/JAXB programmer.&lt;br /&gt;&lt;br /&gt;See &lt;a href="http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo.html"&gt;this article&lt;/a&gt; for easy to use alternatives.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1063388560461943251-4755966475563122385?l=antonywilkins.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antonywilkins.blogspot.com/feeds/4755966475563122385/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antonywilkins.blogspot.com/2009/08/why-not-xml.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1063388560461943251/posts/default/4755966475563122385'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1063388560461943251/posts/default/4755966475563122385'/><link rel='alternate' type='text/html' href='http://antonywilkins.blogspot.com/2009/08/why-not-xml.html' title='Why Not XML?'/><author><name>Antony Wilkins</name><uri>http://www.blogger.com/profile/13733916640946257048</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1063388560461943251.post-1287098226221906659</id><published>2009-08-06T17:34:00.000-07:00</published><updated>2009-08-08T07:26:41.311-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='demo'/><category scheme='http://www.blogger.com/atom/ns#' term='xtext'/><category scheme='http://www.blogger.com/atom/ns#' term='dsl'/><title type='text'>Xtext Spring Demo</title><content type='html'>&lt;h1&gt;Xtext Spring Demo&lt;/h1&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;A powerful alternative to XML&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;XML is, of course, very familiar to programmers. It's used everywhere to configure and pass data between programs.&lt;br /&gt;&lt;br /&gt;In my opinion - it's often not the best choice.  See this &lt;a href="http://antonywilkins.blogspot.com/2009/08/why-not-xml.html"&gt;article on why not&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;But - if you want to skip that - basically I think it's because it's hard on the users of the XML languages (the readers and writers of XML files to whatever schema).&lt;br /&gt;&lt;br /&gt;Why is it used so often if it's to hard to read and write?&lt;br /&gt;&lt;br /&gt;I think it's mostly because XML gives you a lot of free parsing and formatting support.&lt;br /&gt;&lt;br /&gt;Think of the effort required to create an XML parser that creates or configures your application objects.&lt;br /&gt;&lt;br /&gt;You'd take an off-the-shelf package to help with most of the work - a SAX, DOM, or Object (JAXB) parser can be used to quickly integrate a new XML format into your application.&lt;br /&gt;&lt;br /&gt;That's great on one hand - the programming job is done quickly and reliably.  But the end users suffer.&lt;br /&gt;&lt;br /&gt;They'd be much happier with a less verbose (less angle-bracket-y) language, with syntax and grammar tailored to their domain.&lt;br /&gt;&lt;br /&gt;Traditionally this has been hard.  There are well known tools to help create  languages (ANTLR for example) - but they're not easy or quick to use.&lt;br /&gt;&lt;br /&gt;Well - actually - writing custom languages is easy.&lt;br /&gt;&lt;br /&gt;We've sort of been doing it for years.&lt;br /&gt;&lt;br /&gt;Well read software engineers will be used to reading descriptions of languages written in &lt;a href="http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form"&gt;BNF&lt;/a&gt; or &lt;a href="http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form"&gt;EBNF&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Some clever folk at &lt;a href="http://itemis.de"&gt;itemis&lt;/a&gt; and &lt;a href="http://openarchitectureware.org"&gt;openArchitectureWare&lt;/a&gt; have recently contributed their (already open source) project Xtext (as well as others) to the eclipse.org community.&lt;br /&gt;They recently became a part of the Galileo release for eclipse modeling.&lt;br /&gt;&lt;br /&gt;With a few tweaks, EBNF itself can be used as a general purpose language to define new textual languages.&lt;br /&gt;Given just a little extra information, an EBNF-like language can be used as input to a generator that creates a parser, a formatter, a Java model to parse and format, as well as&lt;br /&gt;a sophisticated Eclipse based editor with JDT-like features such as syntax highlighting, code completion and hyperlinking.&lt;br /&gt;&lt;br /&gt;This article will demonstrate how &lt;a href="http://xtext.org"&gt;Xtext&lt;/a&gt; can make the job of creating a parser for any arbitrary language as easy (if not easier than) XML.&lt;br /&gt;&lt;br /&gt;It will also show how to go a lot further - for little or no extra effort.&lt;br /&gt;&lt;br /&gt;The demo is broken down into parts:&lt;br /&gt;&lt;ol&gt;&lt;br /&gt; &lt;li&gt;&lt;a href="http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-1.html"&gt;Spring Demo - Part 1 - Create a new language to define Spring Beans&lt;/a&gt; : Shows how to create a simple Xtext language and sample model file&lt;/li&gt;&lt;br /&gt; &lt;li&gt;&lt;a href="http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-2.html"&gt;Spring Demo - Part 2 - Test our new language - standalone&lt;/a&gt; : Load the sample model file and read it from standalone Java&lt;/li&gt;&lt;br /&gt; &lt;li&gt;&lt;a href="http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-3.html"&gt;Spring Demo - Part 3 - Read a Spring model to load a BeanFactory&lt;/a&gt; : Integration with Spring - loading a BeanFactory from the model file&lt;/li&gt;&lt;br /&gt; &lt;li&gt;&lt;a href="http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-4.html"&gt;Spring Demo - Part 4 - Export Spring XML from model&lt;/a&gt; : Transformation of the model into standard Spring bean definition XML&lt;/li&gt;&lt;br /&gt; &lt;li&gt;&lt;a href="http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo-part-5.html"&gt;Spring Demo - Part 5 - Serialisation of model to text form&lt;/a&gt; : Takes a programatically created model and exports it to the new Xtext Spring language&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;All code and these documents can be downloaded from &lt;a href="https://eclipsecoding.svn.sourceforge.net/svnroot/eclipsecoding/trunk/dsl_demo/spring_demo"/&gt;SVN&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1063388560461943251-1287098226221906659?l=antonywilkins.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://antonywilkins.blogspot.com/feeds/1287098226221906659/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1063388560461943251/posts/default/1287098226221906659'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1063388560461943251/posts/default/1287098226221906659'/><link rel='alternate' type='text/html' href='http://antonywilkins.blogspot.com/2009/08/xtext-spring-demo.html' title='Xtext Spring Demo'/><author><name>Antony Wilkins</name><uri>http://www.blogger.com/profile/13733916640946257048</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
