XMLSnippet: A Coding Assistant for XML Configuration Snippet
Recommendation
Sheng Huang, Yanghua Xiao
*
, Yiqi Lu, Wei Wang
School of Computer Science
Fudan University
Shanghai, China
{shhuang, shawyh, 10210240030,
weiwang1}@fudan.edu.cn
Yu Wang
IBM China Research Lab
Shanghai, China
wangyush@cn.ibm.com
Abstract—Framework-based
1
applications are quite popularly
used in current commercial applications. Framework-based
applications are often controlled by XML configuration files.
However, most of these frameworks are complex or not well
documented, which poses a great challenge for programmers
to correctly utilize them. To overcome these difficulties, we
propose a new method to recommend XML configuration
snippets automatically through mining tree patterns from the
application repository with the aim of assisting the
programmer to generate proper XML configurations during
the product phase. This method is further realized into a new
tool XMLSnippet. In this paper, we will systematically present
the core techniques of the proposed method, including closed
frequent tree pattern mining, prefix tree based indexing and
three types of queries (type query, structural query and
context query) for online coding assistance. Experimental
results show that these techniques are efficient for
recommending reusable XML configuration snippets and
consequently improve the productivity of programmers
effectively with the assistance of the tool when they program
with XML-based frameworks.
Keywords- XML; Code Reuse ; Code Generation
I. INTRODUCTION
In today’s software development, developers often utilize
XML based frameworks to simplify implementation or make
the programs more structural. Developers in general need to
develop XML configuration files and client code to
implement framework-based programs. See Fig. 1 as an
example. To implement the typical login logic by Struts (one
widely used framework to implement MVC in Java Web
Applications), we need to build the XML configuration (Fig.
1(b)) and the client code (Fig 1(a)). Generally speaking, in
this kind of framework- based programming, the imported
framework packages (Jars for Java based frameworks) and
the XML configuration files work together with client code
to control the logic of the application.
Despite the benefits of framework-based programming,
correctly and effectively utilizing the frameworks is still a
great challenge. In reality, defects are easily introduced into
the software due to the following reasons. (1) Documentation
is always insufficient or is badly produced for a multitude of
*
correspondence author: Yanghua Xiao (shawyh@fudan.edu.cn)
reasons. (2) It is usually the case that programmers
improperly edit the XML configuration files while the IDE
(Integrated Development Environment) gives no prompt
messages. These facts lead to incorrect and inefficient usage
of the frameworks in the coding phase.
Automatic code recommendation is one of promising
solutions to reduce the probability of introducing defects
caused by the complexity of frameworks or
misunderstanding of poor documentation. In framework-
based applications, code recommendation for XML
configuration file building is expected to generate reusable
XML substructure, sub elements/attributes, or samples to
input element/attribute values so as to assist building XML
configuration files for target application.
By automatic code recommendation, we can assist
coding in the following target scenarios. For example, when
using Struts, a freshman may often meet the following
problems: “I know I need to use Struts, but I do not know the
basic elements that I need to input ”; “I know I need to use
the <action mapping> element to manage the action mapping
of UI logic, but I do not know the proper attributes and sub-
elements combination that I need to use”; “I know I need to
use some attributes to decorate an action element, but I don’t
know what value to input as the attribute value”, etc.
However, to the best of our knowledge, no existing
academic work addressed the problem of recommending
code for XML configuration file building, which is a
distinctive and important part of programming with
frameworks. Most of previous academic works [2-6, 8, 9]
focus on recommending language-level sample code through
simple association rule, sequence associations, etc. Their
solutions cannot be applied for code recommendation in
framework-based programming due to the structural
complexity of XML configuration files, and semantic
complexity of application context, etc.
Neither existing open source/commercial industrial tools
can be directly applied for code assistance scenarios required
in framework-based programming. Tools like Eclipse [2],
Eclipse XML Editor [20], and Visual Studio 2010 [18] could
only generate XML snippets based on templates or XML
Schema. None of them can recommend XML code based on
the application context or the frequently used
elements/attributes combination
Automatic code recommendation for framework-based
programming now is possible due to the availability of (1)
2012 IEEE 36th International Conference on Computer Software and Applications
0730-3157/12 $26.00 © 2012 IEEE
DOI 10.1109/COMPSAC.2012.42
307
2012 IEEE 36th International Conference on Computer Software and Applications
0730-3157/12 $26.00 © 2012 IEEE
DOI 10.1109/COMPSAC.2012.42
307
2012 IEEE 36th International Conference on Computer Software and Applications
0730-3157/12 $26.00 © 2012 IEEE
DOI 10.1109/COMPSAC.2012.42
310
2012 IEEE 36th International Conference on Computer Software and Applications
0730-3157/12 $26.00 © 2012 IEEE
DOI 10.1109/COMPSAC.2012.42
312