Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
4.4 KiB

  1. <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" language="VBScript" >
  2. <!-- Copyright (c) 2001 Microsoft Corporation -->
  3. <xsl:script><![CDATA[
  4. Option Explicit
  5. 'This stylesheet formats DMTF XML encoded CIM objects into a tabular
  6. 'format using carriage returns and space characters only.
  7. Dim sPXML
  8. Dim bFirst
  9. Dim sTs(128)
  10. Dim lens(128)
  11. Dim bN(100)
  12. Dim iLens
  13. Dim iLensMax
  14. Dim sVs(2048, 128)
  15. Dim iRow
  16. Dim iResultCount
  17. Function DispIt0(n)
  18. iResultCount = iResultCount + 1
  19. End Function
  20. Function PadIt(ilen)
  21. Dim s
  22. Dim i
  23. Dim sp
  24. if ilen >= 0 then
  25. i = Abs(ilen) + 2
  26. else
  27. i = 1
  28. end if
  29. If i > 200 Then
  30. While i > 0
  31. s = s & " "
  32. i = i - 1
  33. Wend
  34. PadIt = s
  35. Else
  36. PadIt = Left(" ", i)
  37. End If
  38. End Function
  39. Function DispIt1(n)
  40. Dim sT
  41. If Len(sPXML) = 0 Then
  42. sPXML = Me.ParentNode.xml
  43. bFirst = True
  44. If iResultCount > 1 then
  45. sTs(iLens) = "Node"
  46. sVs(iRow, iLens) = Me.ParentNode.ParentNode.ParentNode.Attributes(0).Value
  47. iLens = iLens + 1
  48. End If
  49. End If
  50. If Me.ParentNode.xml <> sPXML Then
  51. sPXML = Me.ParentNode.xml
  52. bFirst = False
  53. iLensMax = iLens
  54. iLens = 0
  55. iRow = iRow + 1
  56. If iResultCount > 1 then
  57. sTs(iLens) = "Node"
  58. sVs(iRow, iLens) = Me.ParentNode.ParentNode.ParentNode.Attributes(0).Value
  59. iLens = iLens + 1
  60. End If
  61. End If
  62. If Left(Me.Attributes(0).Value,1) = "_" Then
  63. Exit Function
  64. End If
  65. If bFirst Then
  66. 'this is the first row - set up the headers
  67. sTs(iLens) = Me.Attributes(0).Value
  68. Else
  69. If sTs(iLens) <> Me.Attributes(0).Value Then
  70. 'This is going to be messy - Find it or add it on the end
  71. End If
  72. End If
  73. if IsNumeric(Me.nodeTypedValue) then
  74. if bN(iLens) < 2 then
  75. bN(iLens) = 1
  76. End If
  77. sT = Me.FormatNumber(Me.nodeTypedValue, "###,###,###,###.####")
  78. If Mid(sT, Len(sT),1) = "." then
  79. sT = Me.FormatNumber(Me.nodeTypedValue, "###,###,###,###")
  80. End If
  81. sVs(iRow, iLens) = sT
  82. Else
  83. sVs(iRow, iLens) = Me.nodeTypedValue
  84. bN(iLens) = 2
  85. End If
  86. iLens = iLens + 1
  87. End Function
  88. Function DispIt2(n)
  89. Dim sT
  90. Dim sV
  91. Dim i
  92. Dim j
  93. Dim k
  94. 'Determine the column widths
  95. 'look at the column headers first
  96. iLensMax = iLens
  97. iLens = 0
  98. iRow = iRow + 1
  99. While i < iLensMax
  100. k = Len(sTs(i))
  101. If k > lens(i) Then
  102. lens(i) = k
  103. End If
  104. i = i + 1
  105. Wend
  106. 'look at the values
  107. i = 0
  108. While i < iRow
  109. j = 0
  110. While j < iLensMax
  111. k = Len(sVs(i, j))
  112. If k > lens(j) Then
  113. lens(j) = k
  114. End If
  115. j = j + 1
  116. Wend
  117. i = i + 1
  118. Wend
  119. 'set up the column headers
  120. i = 0
  121. While i < iLensMax
  122. j = lens(i)
  123. j = j - Len(sTs(i))
  124. If bN(i) = 1 then
  125. sT = sT & PadIt(j-1) & sTs(i) & " "
  126. Else
  127. sT = sT & sTs(i) & PadIt(j)
  128. End If
  129. i = i + 1
  130. Wend
  131. i = 0
  132. While i < iRow
  133. j = 0
  134. While j < iLensMax
  135. k = lens(j) - Len(sVs(i, j))
  136. if bN(j)= 1 then
  137. sV = sV & PadIt(k-1) & sVs(i, j) & " "
  138. Else
  139. sV = sV & sVs(i, j) & PadIt(k)
  140. End If
  141. j = j + 1
  142. Wend
  143. sV = sV & vbCrLf
  144. i = i + 1
  145. Wend
  146. DispIt2 = sT & vbCrLf & sV
  147. End Function
  148. ]]></xsl:script>
  149. <xsl:template match="/"><xsl:apply-templates select="//RESULTS"/><xsl:apply-templates select="//INSTANCE"/><xsl:eval language="VBScript">DispIt2(this)</xsl:eval></xsl:template>
  150. <xsl:template match="RESULTS"><xsl:eval language="VBScript">DispIt0(this)</xsl:eval></xsl:template>
  151. <xsl:template match="INSTANCE"><xsl:apply-templates select="PROPERTY"/></xsl:template>
  152. <xsl:template match="PROPERTY"><xsl:eval language="VBScript">DispIt1(this)</xsl:eval></xsl:template>
  153. </xsl:stylesheet>