<?xml version="1.0"?>
<!-- By James Murray - taken from http://preview.tinyurl.com/2g96ow6 -->
<!-- file name should be mystyle.xsl -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="RESULTS">
<xsl:for-each select="CIM/INSTANCE">
<xsl:sort select="PROPERTY[@NAME='Name']|PROPERTY.ARRAY[@NAME='Name']|PROPERTY.REFERENCE[@NAME='name']"/>
<xsl:for-each select="PROPERTY|PROPERTY.ARRAY|PROPERTY.REFERENCE">
<xsl:variable name="typevar" select="@TYPE"/>
<xsl:copy><xsl:value-of select="@NAME"/></xsl:copy>
<xsl:for-each select="VALUE|VALUE.ARRAY|VALUE.REFERENCE">
<xsl:apply-templates select=".">
<xsl:with-param name="type">
<xsl:value-of select="$typevar"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<xsl:template match="VALUE">
<xsl:param name="type"/>
<xsl:param name="includequotes"/>
<xsl:param name="isarray"/>
<xsl:choose>
<xsl:when test="$type='string'">
<xsl:if test="$includequotes='true'">"</xsl:if><xsl:copy><xsl:value-of select="."/></xsl:copy><xsl:if test="$includequotes='true'">"</xsl:if>
</xsl:when>
<xsl:when test="$type='char16'">
<xsl:copy><xsl:value-of select="."/></xsl:copy>
</xsl:when>
<xsl:when test="$type='uint16'or $type='uint32' or $type='uint64' or $type='uint8' or $type='real32'or $type='real64' or $type='sint16'or $type='sint32' or $type='sint64' or $type='sint8'">
<xsl:if test="not($isarray='true')"><xsl:copy><xsl:value-of select="."/></xsl:copy></xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:copy><xsl:value-of select="."/></xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="/" >
<element>
<xsl:apply-templates select="COMMAND/RESULTS"/>
</element>
</xsl:template>
</xsl:stylesheet>