Workload Manager Policy in XML Format – Part III

(Originally posted 2009-04-08.)

Here’s another way to process a WLM Service Definition – once you’ve got it into XML format.

XSLT (XML Stylesheet Transformations if you prefer) is another technology that’s been around for a while.

In simple terms you write another piece of XML (the stylesheet) that describes how to transform your original XML into something else. There’s a lot of flexibility in this but the example in this post is plain old HTML as a target.

There are lots of tools to take the XSLT file and use it to transform the original XML. In my case I’m using a java-based free engine(Saxon)but you could, for example, do it from javascript. Saxon’s command-line based and works fast and well – for my purposes.

So here’s a sample XSLT file:

<?xml version="1.0"?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:wlm="http://www.ibm.com/WLM/ServiceDefinition/Level008">

<xsl:output method="xhtml" /> <xsl:template match="/"> <xhtml> <body> <h1><xsl:value-of select="wlm:ServiceDefinition/wlm:Name"/> - <xsl:value-of select="wlm:ServiceDefinition/wlm:Description"/></h1> <table border="1"> <tr> <th>Name</th> <th>Description</th> <th>Subsystem Type</th> <th>Limit</th> <th>Procedure Name</th> <th>Start Parameters</th> </tr> <xsl:apply-templates select="wlm:ServiceDefinition/wlm:ApplicationEnvironments/wlm:ApplicationEnvironment"/> </table> </body> </xhtml> </xsl:template>

<xsl:template match="wlm:ServiceDefinition/wlm:ApplicationEnvironments/wlm:ApplicationEnvironment"> <tr> <td><xsl:value-of select="wlm:Name"/></td> <td><xsl:value-of select="wlm:Description"/></td> <td><xsl:value-of select="wlm:SubsystemType"/></td> <td><xsl:value-of select="wlm:Limit"/></td> <td><xsl:value-of select="wlm:ProcedureName"/></td> <td><xsl:value-of select="wlm:StartParameter"/></td> </tr> </xsl:template>

</xsl:stylesheet>

Again, I’m showing you a sample that handles a different fragment of the Service Definition.

In this case it’s the Application Environment definitions (most notably for use with DB2 Stored Procedures). The stylesheet does two things.

  • Shows the Service Definition name and associated description.
  • Lists in a table information about each Application Environment. (For me the most interesting thing here is the NUMTCB value.)

The “wlm:” throughout is required because the XML file has a namespace associated with it. So all the searches have to respect that. An example of such a search is

match="wlm:ServiceDefinition/wlm:ApplicationEnvironments/wlm:ApplicationEnvironment">

Searches in XSLT are in XPath format. Basically this one says “match on ApplicationEnvironment elements within ApplicationEnvironments elements within the ServiceDefinition element, respecting the use of the namespace “wlm” which is really “http://www.ibm.com/WLM/ServiceDefinition/Level008&#8221;.

As both XPath and XSLT are widely documented on the web (and because this is a technology I’m still almost at the bottom of the learning curve for) I won’t describe the code any further. Again I’d suggest you try it, having taken a text editor to your XML-format Service Definition, and then play with it some.

(Annoyingly there’s an emoticon that appeared in the code instead of “xmlns : xsl” and you’ll need to take the spaces out of this to make it work.)

This is and XSLT file I wrote myself. It was a little fiddly at first but now I think it’s quite easy to understand and modify. But I know I’ve missed many tricks, XSLT and XPath being incredibly powerful.

Have fun playing!

Published by Martin Packer

.

One thought on “Workload Manager Policy in XML Format – Part III

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: