O'Reilly logo

SOA in Practice by Nicolai M. Josuttis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Tools

So far I haven't discussed tools for model-driven development. Because nowadays, almost every modeling language uses XML-based formats, one tool for transformations and/or code generations might be obvious: eXtensible Stylesheet Language Transformations, or XSLT. XSLT, however, has some limitations, which I will discuss next. I'll then present an alternative.

XSLT

With XSLT, an XSLT processor transforms one or more XML files into one or more result files, which might be in XML or any other text form. The transformations are defined by one or more XSLT stylesheet files. These files provide templates for the resulting code, spiced with control structures to iterate over input tokens and placeholders to fill in certain data derived from the source files (see Figure 18-12).

XSLT transformations

Figure 18-12. XSLT transformations

For example, say you had the following service description:

<service name="getContractData">
  <param mode="in">
    <name>contractId</name>
    <type>long</type>
  </param>
  <param mode="out">
    <name>firstName</name>
    <type>string</type>
  </param>
  <param mode="out">
    <name>lastName</name>
    <type>string</type>
  </param>
  <param mode="out">
    <name>isActive</name>
    <type>boolean</type>
  </param>
</service>

A transformation according to the following stylesheet:

<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/service"> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required