XTaGe: a flexible generation system for complex XML collections
Abstract
We introduce XTaGe (XML Tester and Generator), a system for the synthesis of XML collections meant for testing and micro benchmarking applications. In contrast with existing approaches, XTaGe focuses on complex collections, by providing a highly extensible framework to introduce controlled variability in XML structures. In this paper we present the theoretical foundation, internal architecture and main features of our generator; we describe its implementation, which includes a GUI to facilitate the specication of collections; we discuss how XTaGe's features compare with those in other XML generation systems; finally, we illustrate its usage by presenting a use case in the bioinformatics domain
Full text
XTaGe: A flexible generation system for complex XML collections Mar´ıa P´erez, Ismael Sanz, and Rafael Berlanga Universitat Jaume I, Spain {mcatalan,isanz,berlanga}uji.es Abstract. We introduce XTaGe (XML Tester and Generator), a system for the synthesis of XML collections meant for testing and microbenchmarking applications. In contrast with existing approaches, XTaGe focuses on complex collections, by providing a highly extensible framework to introduce controlled variability in XML structures. In this paper we present the theoretical foundation, internal architecture and main features of our generator; we describe its implementation, which includes a GUI to facilitate the specification of collections; we discuss how XTaGe’s features compare with those in other XML generation systems; finally, we illustrate its usage by presenting a use case in the Bioinformatics domain. 1 Introduction Testing is an essential step in the develoment of XML-oriented applications and in most practical settings, this requires the creation of synthetic data. Existing XML generators focus on either the creation of collections of a given size (for stress testing and workload characterization purposes) or with a fixed schema and little variation. These systems do not suit the requirements of an emerging class of important applications in fields such as Bioinformatics and GIS, which have to deal with large collections that present complex structural features, and specialized content such as protein sequences or vectorial map data. In this context, the main drawback of existing systems in our application context is the lack of extensibility, since all systems are limited by the support of a limited number of predefined generation primitives. Another limitation is the uneven support for the introduction of controlled variability in generated structures, useful for example for micro-benchmarking purposes. Finally, the specification of collections is generally done through the manual creation of a text-based specification file, which can be tedious and error-prone. In this paper we introduce XTaGe (XML Tester and Generator), which focuses on the creation of collections with complex structural constraints and domain-specific characteristics. XTaGe contributes (i) a flexible componentbased framework to create highly tailored generators, (ii) a ready-made set of components that model common patterns that arise in complex collections, (iii) easy adaptability to new use cases using a high-level language (XQuery itself)
The resulting system makes it possible to generate test collections whose characteristics would be very difficult, or impossible, to replicate using the existing generic XML generators. Related work. As indicated above, current approaches for generating synthetic XML data can be classified as either schema-unaware or template-based. The former are based on the specification of a few global structural characteristics, such as maximum depth, fan-out and amount of textual data. They are commonly used in benchmarking applications. Examples include Niagdatagen [2], xmlgen (developed for the XMark [16]) and genxml (used in the X007 Benchmark [5]). In contrast, template-based generators use as input an annotated schema that precisely describe the desired structure of the output documents. The bestknown example is ToXgene [4], which defines an extension of XML Schema, the Template Specification Language (TSL) to describe the generated XML document content. It has some support for generating variability through the use of probability distributions to create heterogeneous structures. Many benchmarks applications, such as [17] and [14], generate their testing collections using ToX- gene. Other examples of template-based generators are: VeXGene [10], MeM- BeR [3] and [6], which bases the XML data generation on a DTD and examples of XML instances and support the specifications of constraints of the generated collection, such required XPath expressions. As a special case, other approaches attempt to create new collections by transforming existing ones, such as [7], which can adapt existing documents for experiments meant to evaluate semantic query optimization methods; they provide a set of four transformations to adapt existing XML documents. Another relevant system is [15], which can modify the content of XML documents by creating duplicates or by removing content of the documents in order to create “dirty” documents suitable for testing data cleaning algorithms. Outline of the paper. The remainder of this paper is structured as follows. First, the foundations of XTaGe are presented in Section 2. Then, the XTaGe component-based framework is described in detail in Section 3. In Section 4 we present the prototype and a use case that shows an application of the generation model. Finally, Section 5 presenta a short discussion of XTaGe’s features and introduces directions of future work. 2 Foundations of XTaGe One of the main goals of XTaGe is to provide precise control of the generated data when creating heterogeneous collections and, as a consequence, we will use template-based techniques as a basis for our approach. In this section we provide a formal basis for the definition of XML generators, which will allow us to define a flexible mechanism for the creation and adaptation of XML generators for complex domains. We adopt the XML Store [9] as a suitable abstraction of XML collections, which is commonly used in the context of XML update languages. Following [8],
we will use the following notations: the set Adenotes the set of all atomic values, Vis the set of all nodes, S ⊆ A is the set of all strings, and N ⊆ S is the set of strings that may be used as tag names. The set Vis partitioned into the sets of document nodes (Vd), element nodes (Ve), attribute nodes (Va), and text nodes (Vt). Definition 1 (XML Store). An XML store is a 6-tuple St = (V, E, <, ν, σ, δ) where: –Vis a finite subset of V; we write Vdfor V∩ Vd(resp. Vefor V∩ Ve,Va for V∩ Va,Vtfor V∩ Vt); –(V, E)is an acyclic directed graph (with nodes Vand directed edges E) where each node has an in-degree of at most one, and hence it is composed of trees; if (m, n)∈Ethen we say that nis a child of m; we denote by E∗the reflexive transitive closure of E; –<is a strict partial order on Vthat compares exactly the different children of a common node. Hence for two distinct nodes n1and n2it holds that ((n1< n2)∨(n2< n1)) ⇔ ∃m∈V((m, n1)∈E∧(m, n2)∈E)) –ν:Ve∪Va→ N labels the element and attribute nodes with their node name –σ:Va∪Vt→ S labels the attribute and text nodes with their string value –δ:S → Vda partial function that associates a document node with an URI or a file name. It is called the document function. This function represents all the URIs of the Web and all the names of the files, together with the documents they contain. We suppose that all these documents are in the store. The following properties must hold for an XML store: each document node of Vdis the root of a tree and has only one child element; attribute nodes of Vaand text nodes of Vtdo not have any children; in the <-order attribute children precede the element and text children, i.e. if n1< n2and n∈Vathen n1∈Va; there are no adjacent text children, i.e. if n1, n2∈Vtand n1< n2 then there is an n3∈Vewith n1< n3< n2; for all text nodes ntof Vtholds σ(nt)6= ”” ; all the attribute children of a common node have a different name, i.e. if (m, n1),(m, n2)∈Eand n1, n2∈Vathen ν(n1)6=ν(n)2. Given an XML Store St we will use following auxiliary notations and functions: –VSt,ESt,νSt,σSt and δSt return the corresponding components of St. We also define Vd St,Ve St and Va St. –genDocNode(), genElement(), genAttribute() return members from Vd,Ve and Vawhich do not exist in Vd St,Ve St and Va St respectively. These functions are abstractions of the creation of new element document and attribute nodes. Note that text nodes will be generated by appropriately specific functions. –root(St) is the root node of the store. –descendantsSt(n) is the set of all nodes in St which are descendants of n.
For simplicity, and without loss of generality, in the remainder of this paper we will ignore the partial order <, and we will not indicate the name of the XML Store when it is obvious from context. 2.1 Creating XML documents from scratch We will model XML generators as functions that create XML Stores. Like in other schema-based systems, the generation will be based on the specification of abase model, whose expressivity must be the same of XML Schema languages ([13]). Definition 2 (base model, generator, interpretation). An XTaGe base model,M, is a tree that represents a generating functional expression (or generator, for short) fwhose interpretation GenM(f)is an XML store. A base model is, therefore, conceptually similar to the expression trees that appear when parsing programming languages. For example, consider the following operation: Example 1. Given a generator model tree M, The element(name) component is a generating functional expression whose interpretation GenM(element(name)) generates a XML Store (V, E, <, ν, σ, δ) such that: –newNode =genElement(), that is, a new node –V={newNode} ∪ VGen(ci)for each ci∈childrenT(c) –E={(newNode, root(Gen(ci))} ∪ (SEGen(ci)) for each ci∈childrenT(c) –ν={(newNode, name)}∪(S{(a, b) : (a, b)∈νGen(ci)}) for each ci∈childrenT(c) –δ=S{(a, b):(a, b)∈δGen(ci)}for each ci∈childrenT(c) –σ=S{(a, b):(a, b)∈σGen(ci)}for each ci∈childrenT(c) where childrenM(c) represents the children of node cin the generation model tree M. We treat the attribute nodes similarly.1 Figure 1 represents a simple generation tree that uses the element generator. element(root) element(a)element(b) (a) <root> <a/> <b/> </root> (b) Fig. 1. A simple tree generation using the element generator component and the corresponding XML tree. 1The main difference with the treatment of element nodes is that the attribute nodes cannot be nested.
In order to provide a functionality similar to basic XML Schema, we introduce the following generators that account for the possible content models: –sequence(name, attr, n, minOccurs, maxOccurs): A functional component that is a generalization of the previously introduced element, including support for attributes (attr) a number of repetitions (n) and cardinality constraints (minOccurs and maxOccurs). –choice(name, attr, n, minOccurs, maxOccurs): A functional equivalent of the XML Schema choice content model, represented by a bar (|) in DTDs. The features of the generation model presented so far support the creation of XML documents based on a fixed XML-like schema. We now introduce two features which are specifically designed to introduce controlled variability in collections: distributions and probability-labeled arcs. Value distributions. In XTaGe, every value is extracted from a probability distribution, including constant numbers and strings (which are considered to be extracted from a suitably defined constant distribution). This includes: –Parameters of functional components, for example the number of repetitions nin sequences or choices. –Synthetic content in attributes or text nodes. This allows us to easily express empirical properties of the generated data, such as that the number of children of a given node is normally distributed, or Zipf-like distribution for words in textual content. Probability-labeled tree arcs. Another mechanism to introduce controlled variability in generated XML is introducing the notion of probabilistic labeling. Each arc (u, v) in a generator tree Mis labeled with a probability value p((u, v)) ∈ [0,1].The meaning of a probability-labeled arc is that the child functional expression vwill be ignored with probability 1 −p((u, v)). Example 2. Figure 9 shows a simple generator tree that includes probabilitylabeled arcs, and some of the XML trees that could be generated by it. element(root) element(a) 0.5 element(b) 0.7 (a) <root> <a/> </root> (b) <root> <b/> </root> (c) <root/> (d) <root> <a/> <b/> </root> (e) Fig. 2. A generator tree with probabilistic arcs and some possible generated trees.
2.2 Transforming XML documents The second mechanism by which a new XML collection may be generated is by the controlled transformation of an existing one. Analogously to tree generation model trees, we introduce a transforming functional expressions (or transformations, in short).Moreover, these transformations provide the foundations required to model global contraints over XML documents. Since there are many transformation languages available for XML (XSLT, XDuce), we will focus in the introduction of controlled variability into XML collections through the definition of transforms. Definition 3 (locator). Alocator is a function that takes an XML Store St and returns an XML Store St0such that: –V0 St ⊆VSt –E0 St ⊆ESt –St0is well formed according to Definition 1 Example 3. Given a locator and an XML Store St, the delChild transformation removes a random child of the root node of a tree with probability p, and returns a new XML Store St0. We can define it as follows: –Choose a node n∈children(root(l)), where lis the subtree induced by the locator, with probability p. –VSt0=Vl\({n} ∪ descendantsl(n)) –ESt0=El\{(u, v) such that u, v ∈ {n} ∪ descendants(n)} –νSt0,δSt0and σSt0are suitably modified. Probability-labeled tree arcs are also used in transformation trees to determine if a transformation will be applied or not in the XML documents. It is important also to remark that transformations are applied on the original XML Store, and not on a “different” XML store induced by the locator, which must then be grafted on the original tree. This property allows us to define meta-transformation operations, which can be used to combine different transformations into complex operations. The main meta-transformation is the macro-transformation: Definition 4 (macro-operation). Given an XML Store St and list of (locator, transformation) pairs, the macro-operation macroSt[(l1, t1),...,(ln, tn)] is defined as the sequential application of all pairs to St. 3 Component-based framework The concepts outlined in the previous section have been realized in XTaGe by means of a lightweight component-oriented software model, outlined in Figure 3. The use of components as an abstraction of the generation and transformation functional expressions has a number of benefits directly related to the goals of XTaGe.
First of all, it makes metadata about components and their relationships explicit. This facilitates greatly the construction of support tools such as GUIs, and it also allows the simplified creation of new components without requiring the modification of the XTaGe code. This can be accomplished by a simple twostage process: (i) create the function in a high-level language (XQuery in our case, as we will explain presently) and (ii) register it by filling in the appropriate metadata. For the most complex cases (usually involving calling external libraries), new components can be coded by implementing the appropriate interface. Libraries of related components (e.g. for testing of biomedical data sets) may be put together and maintained independently. Fig. 3. Simplified UML diagram of the XTaGe component architecture. 3.1 Generators in XTaGe In addition to the basic XML Schema-related components described in Section 2, a number of components useful for the generation of collections with controlled variability are pre-defined: XOR This generator chooses one node between all its descendants according to their xor probability values. The descendants of a XOR constructor have an additional probability parameter, xor probability, which determines the likelihood of a node of being chosen by its parent. Combi This generator creates a new node whose tag is a combination of the tags of its descendants. DminDmax The functionality of this generator is creating a new node located nlevels below its ancestor. The value of ndepends on the values of the
attributes dmin and dmax of the constructor. The value of nis a random number between dmin and dmax. IfAncestor This generator determines if a node appears in the new document depending on the tag of its ancestor. An XML node generated by one of these components is assigned a unique id value, which can be specified by the user, automatically by the system, or by a user-defined function. Attributes (and IDREFs, which are treated as a special case) can be defined by the user in the generator model tree. As mentioned above, the preferred way to create new components is by means of the creation of an XQuery functions. XQuery was chosen because it is inherently well-suite to define operations on XML trees. The function must conform to the following signature: declare function component−name($comp as node()) as node()∗; where $comp represents the component metainformation (serialized as XML), including its parameters. To support the creation of components, a library of XQuery functions has been defined that permits access to the defined distributions and the structure of the model tree. Example 4. The following XQuery function implements the component DminDmax, using an auxiliary function to handle recursion: declare function dmindmax($comp as node())) as node()∗ { let $dist := $comp/param/dist return dmindmax aux($comp, $dist) } declare function dmindmax aux($comp as node()∗, $dist)) as node()∗ { if ($dist = 1) then xtg:create node($comp) else(let $actual dist := xs: integer($dist) −1 let $random tag := xtg::randomTag() return element{$random tag} {dmindmax aux($comp, $actual dist)}) } where library function xtg:create node($comp) creates an element based on the parameters of the component and xtg:randomTag() returns random strings. Note the use of XPath to extract the value of the parameters from the component metadata object. Besides the $comp parameter, the component accepts $dist, that is a number obtained from a user-defined distribution that must lie between the values of the parameters dmin and dmax of the component. 3.2 Transformations in XTaGe In order to apply controlled transformations, XTaGe includes a few pre-defined XML transformation components:
Add This transformation component takes as input two XML trees, t1and t2. The component adds t2to t1as a descendant of the node or nodes of t1 determined by the component locator. Delete This component removes the node determined by the component locator of the XML document tree. The component has a parameter called recursive, whose value determines if the operation is executed recursively or not. If its value is 1, the node and all its descendants are removed; if its value is 0, only the node is removed and its descendants occupy its place. In case the nodes have references, XTaGe allows the user to specify whether the references must be automatically re-calculated. Change Order This component changes the order of a node and one of its siblings by changing their positions. The user has to determine the ancestor of the node that is going to be changed and, optionally, the node that is going to change its position. If the user does not specify this node, the component chooses a descendant of the ancestor node randomly. The user can also determine the new position of the node; in case the user does not specify it, the component determines randomly the new position. Change Level This component changes the position of a node and one of its descendants, chosen by the user or randomly. The descendant will be now the ancestor of its siblings and its ancestor will become one of its descendants. XTaGe also allows the definition of new transformations using XQuery. The functions must conform to the following signature: declare function component−name($context as node(), $locator as node()∗, $comp as node()) as node()∗; where $context represents the current context node in the source XML document, that defines where the transformation will be applied; $locator is the set of nodes induced by the locator; and $comp contains metainformation about the component. Example 5. The XQuery function that implements the functionality of the component Change order may be implemented as follows: declare function change order($context, $loc, $config) as node()∗ { let $newpos:= xtg:newPos($config) let $child:= xtg:child($context, $config) let $sibling:= xtg: sibling ($context, $config) return element{fn:local−name($context)} {for $att in $context/@∗ return attribute{fn:local−name($att)}{$att}, for $c at $pos in $context/∗ return if ($pos = $newpos) then xtg:traverse($child, $context, $config) else (if ($c is $child) then xtg:traverse($sibling , $context, $config) else xtg:traverse($c,$context, $config))} }