Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

wmic xsl stylesheet for xml output (mystyle.xsl)

By: a guest on Jan 5th, 2011  |  syntax: XML  |  size: 1.76 KB  |  views: 80  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?xml version="1.0"?>
  2. <!-- By James Murray - taken from  http://preview.tinyurl.com/2g96ow6 -->
  3. <!-- file name should be mystyle.xsl -->
  4. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  5. <xsl:template match="RESULTS">
  6. <xsl:for-each select="CIM/INSTANCE">
  7. <xsl:sort select="PROPERTY[@NAME='Name']|PROPERTY.ARRAY[@NAME='Name']|PROPERTY.REFERENCE[@NAME='name']"/>
  8. <xsl:for-each select="PROPERTY|PROPERTY.ARRAY|PROPERTY.REFERENCE">
  9. <xsl:variable name="typevar" select="@TYPE"/>
  10. <xsl:copy><xsl:value-of select="@NAME"/></xsl:copy>
  11. <xsl:for-each select="VALUE|VALUE.ARRAY|VALUE.REFERENCE">
  12. <xsl:apply-templates select=".">
  13. <xsl:with-param name="type">
  14. <xsl:value-of select="$typevar"/>
  15. </xsl:with-param>
  16. </xsl:apply-templates>
  17. </xsl:for-each>
  18. </xsl:for-each>
  19. </xsl:for-each>
  20. </xsl:template>
  21. <xsl:template match="VALUE">
  22. <xsl:param name="type"/>
  23. <xsl:param name="includequotes"/>
  24. <xsl:param name="isarray"/>
  25. <xsl:choose>
  26. <xsl:when test="$type='string'">
  27. <xsl:if test="$includequotes='true'">"</xsl:if><xsl:copy><xsl:value-of select="."/></xsl:copy><xsl:if test="$includequotes='true'">"</xsl:if>
  28. </xsl:when>
  29. <xsl:when test="$type='char16'">
  30. <xsl:copy><xsl:value-of select="."/></xsl:copy>
  31. </xsl:when>
  32. <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'">
  33. <xsl:if test="not($isarray='true')"><xsl:copy><xsl:value-of select="."/></xsl:copy></xsl:if>
  34. </xsl:when>
  35. <xsl:otherwise>
  36. <xsl:copy><xsl:value-of select="."/></xsl:copy>
  37. </xsl:otherwise>
  38. </xsl:choose>
  39. </xsl:template>
  40. <xsl:template match="/" >
  41. <element>
  42. <xsl:apply-templates select="COMMAND/RESULTS"/>
  43. </element>
  44. </xsl:template>
  45. </xsl:stylesheet>