In the WTP – XML Search [step1], I have introduced WTP/XML Search. I would like show you how it’s easy to manage completion, text hover, validation, hyperlink for your own XML files descriptor with WTP/XML Search. I decided to create a little tutorial which will explain you step by step how manage completion, text hover, validation, hyperlink for the JEE web.xml XML file descriptor with WTP/XML Search. web.xml is interesting because it uses 3 types of XML references :
-  reference to Java class : servlet-class, filter-class, listener-class Text node reference to Java class.
-  reference to XML node : servlet-mapping/servlet-name, filter-mapping/filter-name Text node reference to servlet/servlet-name, filter/filter-name Text node.
-  reference to resource file : welcome-file Text node reference to HTML, JSP…resources files.
Here a scheme which show you this 3 types of references with servlet, servlet-mapping and welcome-file XML nodes :
This article show you screenshot about completion, text hover, hyperlink and validation for web.xml. In next article [step3], I will explain how manage that with WTP/XML Search.
Many Java frameworks use XML files configuration to describe the framework behaviour. Spring, Jetty, Tomcat, Struts2, Hibernate… are Java frameworks which are configured with XML files. Take a sample XML file with Spring :
<beans> <bean id="accountDaoBeanId" class="org.springframework.samples.jpetstore.dao.ibatis.SqlMapAccountDao" /> <bean id="petStore" class="org.springframework.samples.jpetstore.services.PetStoreServiceImpl"> <property name="accountDao" ref="accountDaoBeanId"/> </bean> </beans>
In this sample you can notice you have several references :
- XML Node 2 Java class : bean/@class reference a Java class.
- XML Node 2 Java method : bean/property/@name reference the setter SqlMapAccountDao#setAccountDao
- XML Node 2 XML node : bean/property/@ref reference the bean accountDaoBeanId.
- It exists another references like XML node 2 file for instance.
Having a framework which is configured with XML files is cool, but I think it’s very important to have a good IDE which manage thoses XML files. Spring Tools Suite is a great Spring IDE for Eclipse which manage XML Spring files. You can benefit with completion, hyperlink, validation to manage XML references described below. Here a screenshot with completion for ref bean (XML Node 2 XML node) with Spring Tools Suite :
Develop a Spring Tools Suite-like to manage another XML files (Jetty, Struts2, custom XML descriptor..) for Eclipse is very hard. I have decided to create Eclipse WTP – XML Search that I would like to contribute to official WTP project (see bug 330576) which give you 2 features:
- Search/XML… which add new Search UI dialog (like Search/File…, Search/Java…) to search from your workspace, XML nodes and files with XPath as pattern search.
- Use XML search in your plugins which give you the capability to manage completion, hyperlink, validation (and Ctrl+Shift+G) to manage any XML files (Jetty, Struts2…). The basic idea is to declare with the Extenion Point "org.eclipse.wst.xml.search.editor.references" the XML references (XML node 2 XML node, XML node to Java…) for your XML files and you benefit for completion, hyperlink, validation (and Ctrl+Shift+G). The goal of this extension point is to hide the completion, hyperlink, validation complexity development. To give you an idea, I have managed XML Jetty files and Struts2 XML files. For each project I have developped that into 4 hours.
I have decided to write several articles called "Eclipse WTP – XML Search [step*]" where I will present you the 2 features of the Eclipse WTP – XML Search. If you wish see screenshot and test XML Jetty and Struts2 plugins based on Eclipse WTP – XML Search, please read ODT files from TK-UI SVN/docs.