<?xml version="1.0" encoding="UTF-8"?>
<!--
Notice 
DSP8025
Document: Metric Class Generation XLT
Version: 1.0.0a
Status: Preliminary
Date: 12/17/2007
Author: Oliver Benke, Michael Johanssen
Description: XML transformation file used to transform XML message registry into a readable table format. This table format does not print easily due to a known issue with browsers and html tables.

Based on DSP8001 by Steve Hand and Linda Martinez
Revision 0.6 08/10/2007 Oliver Benke
Revision 0.7 08/24/2007 Michael Johanssen
Revision 0.7.2 10/04/2007 Oliver Benke
Revision 0.7.3 11/16/2007 Oliver Benke

Copyright © 2007 Distributed Management Task Force, Inc. (DMTF). All rights reserved. DMTF is a not-for-profit association of industry members dedicated to promoting enterprise and systems management and interoperability. Members and non-members may reproduce DMTF specifications and documents for uses consistent with this purpose, provided that correct attribution is given. As DMTF specifications may be revised from time to time, the particular version and release date should always be noted. Implementation of certain elements of this standard or proposed standard may be subject to third party patent rights, including provisional patent rights (herein "patent rights"). DMTF makes no representations to users of the standard as to the existence of such rights, and is not responsible to recognize, disclose, or identify any or all such third party patent right, owners or claimants, nor for any incomplete or inaccurate identification or disclosure of such rights, owners or claimants. DMTF shall have no liability to any party, in any manner or circumstance, under any legal theory whatsoever, for failure to recognize, disclose, or identify any such third party patent rights, or for such party's reliance on the standard or incorporation thereof in its product, protocols or testing procedures. DMTF shall have no liability to any party implementing such standard, whether such implementation is foreseeable or not, nor to any patent owner or claimant, and shall have no liability or responsibility for costs or losses incurred if a standard is withdrawn or modified after publication, and shall be indemnified and held harmless by any party implementing the standard from any and all claims of infringement by a patent owner for such implementations. For information about patents held by third-parties which have notified the DMTF that, in their opinion, such patent may relate to or impact implementations of DMTF standards, visit http://www.dmtf.org/about/policies/disclosures.php.

Change Requests: 
	None
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:uuid="java.util.UUID" version="2.0">
    <xsl:output method="text" version="4.0" encoding="UTF-8" standalone="no"
        omit-xml-declaration="no" media-type="text/xml" indent="yes"/>
	<xsl:template match="text()|@*" mode="#all"/>
	<!-- Override the default rule !! -->
        <xsl:template match="/">
		<xsl:apply-templates select="/REGISTRY/REGISTRY_ENTRIES/METRIC"/>
	</xsl:template>
	<xsl:template match="REGISTRY/REGISTRY_ENTRIES/METRIC">
          <xsl:text>&#10;&#10;</xsl:text>
                <xsl:apply-templates select="METRIC_DESCRIPTION"/>
                <xsl:text>&#10;instance of CIM_BaseMetricDefinition {</xsl:text>
                <xsl:text>,&#10;    Caption = &quot;</xsl:text>
<xsl:value-of select="LOCALID"/>
                <xsl:text>&quot;,&#10;    Description = &quot;</xsl:text>
<xsl:value-of select="LOCALID"/>
                <xsl:text>&quot;,&#10;    ElementName = &quot;</xsl:text>
<xsl:value-of select="LOCALID"/>
		<xsl:text>&quot;,&#10;    Id=&quot;</xsl:text>
		<xsl:choose>
      			<xsl:when test="system-property('xsl:version') >= '2.0'">
      				<!-- assumes we're running under Eclipse/OrangeVault so we can use randomUUID() method -->
				<xsl:variable name="uuid" select="uuid:randomUUID()"/> 
				<xsl:value-of select="uuid:toString($uuid)"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:text>(vendor defined UUID)</xsl:text>
			</xsl:otherwise>
		</xsl:choose>
                <xsl:text>&quot;</xsl:text>
		<xsl:text>,&#10;    Name = &quot;</xsl:text>
		<xsl:value-of select="METRICID"/>
                <xsl:text>&quot;</xsl:text>
		<xsl:apply-templates select="DATATYPE"/>
		<xsl:apply-templates select="IS_CONTINUOUS"/>
		<xsl:apply-templates select="CHANGE_TYPE"/>
		<xsl:apply-templates select="TIMESCOPE"/>
		<xsl:apply-templates select="GATHERING_TYPE"/>
		<xsl:text>&#10;};</xsl:text>
	</xsl:template>
	<xsl:template match="METRIC/METRIC_DESCRIPTION">
		<xsl:call-template name="DESCRIPTION"/>
	</xsl:template>
	<xsl:template name="DESCRIPTION">
                <xsl:text>// </xsl:text>
                <xsl:value-of select="."/>
	</xsl:template>
	<xsl:template match="METRIC/DATATYPE">
		<xsl:text>&#10;    DataType = </xsl:text>
		<xsl:choose>
			<xsl:when test=".='boolean'">1</xsl:when>
			<xsl:when test=".='char16'">2</xsl:when>
			<xsl:when test=".='datetime'">3</xsl:when>
			<xsl:when test=".='real32'">4</xsl:when>
			<xsl:when test=".='real64'">5</xsl:when>
			<xsl:when test=".='sint16'">6</xsl:when>
			<xsl:when test=".='sint32'">7</xsl:when>
			<xsl:when test=".='sint64'">8</xsl:when>
			<xsl:when test=".='sint8'">9</xsl:when>
			<xsl:when test=".='string'">10</xsl:when>
			<xsl:when test=".='uint16'">11</xsl:when>
			<xsl:when test=".='uint32'">12</xsl:when>
			<xsl:when test=".='uint64'">13</xsl:when>
			<xsl:when test=".='uint8'">14</xsl:when>
		</xsl:choose>
		<xsl:text>; // </xsl:text>
		<xsl:value-of select="."/>
	</xsl:template>
	<xsl:template match="METRIC/CHANGE_TYPE">
		<xsl:text>&#10;    ChangeType = </xsl:text>
		<xsl:choose>
			<xsl:when test=".='Counter'">3</xsl:when>
			<xsl:when test=".='Gauge'">4</xsl:when>
		</xsl:choose>
		<xsl:text>; // </xsl:text>
		<xsl:value-of select="."/>
	</xsl:template>
	<xsl:template match="METRIC/TIMESCOPE">
		<xsl:text>&#10;    TimeScope = </xsl:text>
		<xsl:choose>
			<xsl:when test=".='Point'">2</xsl:when>
			<xsl:when test=".='Interval'">3</xsl:when>
			<xsl:when test=".='StartupInterval'">4</xsl:when>
		</xsl:choose>
		<xsl:text>; // </xsl:text>
		<xsl:value-of select="."/>
	</xsl:template>
	<xsl:template match="METRIC/GATHERING_TYPE">
		<xsl:text>&#10;    GatheringType = </xsl:text>
		<xsl:choose>
			<xsl:when test=".='Unknown'">0</xsl:when>
			<xsl:when test=".='OnChange'">2</xsl:when>
			<xsl:when test=".='Periodic'">3</xsl:when>
			<xsl:when test=".='OnRequest'">4</xsl:when>
			<xsl:when test=".='DMTF Reserver'">?</xsl:when>
			<xsl:when test=".='Vendor Reserved'">?</xsl:when>
		</xsl:choose>
		<xsl:text>; // </xsl:text>
		<xsl:value-of select="."/>
	</xsl:template>
	<xsl:template match="METRIC/IS_CONTINUOUS">
		<xsl:text>&#10;    IsContinuous = </xsl:text>
		<xsl:value-of select="."/>
                <xsl:text>;</xsl:text>
	</xsl:template>
</xsl:stylesheet>
