TTXPath logo
A Tutorial on XMorph
Flexible Querying for XML
Curtis Dyreson
  Contact me

To run the tutorial queries, use the demo code.

We give a short tutorial on XMorph through a series of examples of increasing complexity. The ANTLR syntax for XMorph is available. The examples in this tutorial will transform the data about books written by E. F. Codd shown below.

        <name>E.F. Codd</name>
    <publisher>Addison Wesley</publisher>
      <name>E.F. Codd</name>
    <publisher>Academic Press</publisher>

Though database query languages tend to be declarative rather than functional, XMorph is a functional query language (i.e., similar to a query algebra rather than a query calculus). The transformations are listed below. Each transformation is described and an (on-line demo) example given.

  • MORPH - Transform the data to the specified shape
    • ASATTRIBUTE - Convert an element to an attribute
    • GROUP - Static and dynamic grouping in a MORPH
    • CHILDREN - Retain children from the original shape in the new shape without explictly specifying the children
    • DESCENDANTS - Retain desendants from the original shape in the new shape without explictly specifying the descendants.
  • COMPOSE - Compose transformations
  • MUTATE - Mutate the data's shape
    • CLONE - Copy elements in a mutation
    • DROP - Delete part of the shape while mutating

These examples show a few of the uses of XMorph and illustrate its most important design feature: shape polymorphism. In a shape polymorphic query language users specify only what they want as output. A query adapts to the shape of the input data to produce the desired output. In XMorph, this adaptation is based on the notion of closeness.

Also, the transformations do not describe the shape of the input, that is, a transformation could be applied to data regardless of its shape. Some transformations might lose information so XMorph calculates potential information loss in a transformation. The only shape that the user needs to specify is that of the output.


Curtis E. Dyreson © 2013. All rights reserved.
  E-mail questions or comments to Curtis.Dyreson at