Leaked source code of windows server 2003
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.

180 lines
5.9 KiB

  1. <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
  2. <!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
  3. <xsl:script language="VBScript"><![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 propname(128)
  9. Dim lenarr(128)
  10. Dim bN(128)
  11. Dim iLens
  12. Dim iLensMax
  13. Dim propvalue(2048, 128)
  14. Dim iRow
  15. iRow = -1
  16. Dim iResultCount
  17. Function CountResults(n)
  18. iResultCount = iResultCount + 1
  19. End Function
  20. Function PadIt(ilen)
  21. Dim i
  22. Dim pads
  23. i = ilen + 2
  24. pads = " "
  25. while (i > len(pads))
  26. pads = pads & pads
  27. wend
  28. PadIt = Left(pads, i)
  29. End Function
  30. Function GotInstance()
  31. iLensMax = iLens
  32. iLens = 0
  33. iRow = iRow + 1
  34. End Function
  35. Function GetValues(n)
  36. Dim child, iNum, i, strType
  37. If iRow = 0 Then
  38. 'this is the first row - set up the headers
  39. propname(iLens) = Me.Attributes.GetNamedItem("NAME").Value
  40. Else
  41. If propname(iLens) <> Me.Attributes.GetNamedItem("NAME").Value Then
  42. 'This is going to be messy - Find it or add it on the end
  43. End If
  44. End If
  45. If strcomp(Me.NodeName,"Property.Array",1) = 0 Then
  46. if (Me.hasChildNodes) then
  47. propvalue(iRow, iLens) = "{"
  48. iNum = Me.FirstChild.ChildNodes.Length
  49. i = 1
  50. strType = Me.attributes.getNamedItem("TYPE").nodeValue
  51. For each child in Me.FirstChild.ChildNodes
  52. if (strType = "string") then
  53. propvalue(iRow, iLens) = propvalue(iRow, iLens) & """" & child.nodeTypedValue & """"
  54. elseif (strType = "char16") then
  55. propvalue(iRow, iLens) = propvalue(iRow, iLens) & "'" & child.nodeTypedValue & "'"
  56. else
  57. propvalue(iRow, iLens) = propvalue(iRow, iLens) & child.nodeTypedValue
  58. end if
  59. if (i <> iNum) then
  60. propvalue(iRow, iLens) = propvalue(iRow, iLens) & ", "
  61. end if
  62. i = i + 1
  63. Next
  64. propvalue(iRow, iLens) = propvalue(iRow, iLens) & "}"
  65. end if
  66. ElseIf strcomp(Me.NodeName,"Property.Reference",1) = 0 Then
  67. dim valref, node, hostnode, localnamespace, namespacenode, keybindings, keybinding
  68. for each valref in Me.selectNodes("VALUE.REFERENCE")
  69. for each node in valref.selectNodes(".//NAMESPACEPATH")
  70. set hostnode = node.selectsinglenode("HOST")
  71. if not hostnode is nothing then
  72. propvalue(irow, ilens) = "\\" & hostnode.text
  73. end if
  74. set localnamespace = node.selectsinglenode("LOCALNAMESPACEPATH")
  75. if not localnamespace is nothing then
  76. for each namespacenode in localnamespace.selectnodes("NAMESPACE")
  77. propvalue(irow,ilens) = propvalue(irow,ilens) & "\" & namespacenode.attributes.getNamedItem("NAME").nodeValue
  78. next
  79. end if
  80. propvalue(irow,ilens) = propvalue(irow,ilens) & ":"
  81. next
  82. for each node in valref.selectNodes(".//INSTANCENAME")
  83. propvalue(irow,ilens) = propvalue(irow,ilens) & node.attributes.getNamedItem("CLASSNAME").nodevalue
  84. set keybindings = node.selectnodes("KEYBINDING")
  85. i = 0
  86. for each keybinding in keybindings
  87. i = i + 1
  88. if (i = 1) then
  89. propvalue(irow,ilens) = propvalue(irow,ilens) & "."
  90. end if
  91. propvalue(irow,ilens) = propvalue(irow,ilens) & keybinding.attributes.getnameditem("NAME").nodeValue & "=""" & _
  92. keybinding.selectsinglenode("KEYVALUE").text & """"
  93. if (i <> keybindings.length) then
  94. propvalue(irow,ilens) = propvalue(irow,ilens) & ","
  95. end if
  96. next
  97. next
  98. next
  99. Else
  100. propvalue(iRow, iLens) = replace(replace(Me.nodeTypedValue, vbCr, ""), vbLF, "")
  101. End If
  102. iLens = iLens + 1
  103. End Function
  104. Function DisplayValues(n)
  105. Dim sT
  106. Dim sV
  107. Dim i
  108. Dim j
  109. Dim k
  110. 'Determine the column widths
  111. 'look at the column headers first
  112. iLensMax = iLens
  113. iLens = 0
  114. iRow = iRow + 1
  115. i = 0
  116. While i < iLensMax
  117. k = getlength(propname(i))
  118. If k > lenarr(i) Then
  119. lenarr(i) = k
  120. End If
  121. i = i + 1
  122. Wend
  123. 'look at the values
  124. i = 0
  125. While i < iRow
  126. j = 0
  127. While j < iLensMax
  128. k = getlength(propvalue(i, j))
  129. If k > lenarr(j) Then
  130. lenarr(j) = k
  131. End If
  132. j = j + 1
  133. Wend
  134. i = i + 1
  135. Wend
  136. 'set up the column headers
  137. i = 0
  138. While i < iLensMax
  139. j = lenarr(i) - getlength(propname(i))
  140. sT = sT & propname(i) & PadIt(j)
  141. i = i + 1
  142. Wend
  143. i = 0
  144. While i < iRow
  145. j = 0
  146. While j < iLensMax
  147. k = lenarr(j) - getlength(propvalue(i, j))
  148. if bN(j)= 1 then
  149. sV = sV & PadIt(k-2) & propvalue(i, j) & " "
  150. Else
  151. sV = sV & propvalue(i, j) & PadIt(k)
  152. End If
  153. j = j + 1
  154. Wend
  155. sV = sV & vbCrLf
  156. i = i + 1
  157. Wend
  158. DisplayValues = sT & vbCrLf & sV
  159. End Function
  160. Function GetLength(str)
  161. Dim i, ch
  162. 'we have to manually compute length
  163. GetLength = 0
  164. For i = 1 to len(str)
  165. ch = ascw(mid(str,i,1))
  166. if (ch > 255) or (ch < 0) then
  167. GetLength = GetLength + 2 'assume two byte spaces
  168. else
  169. GetLength = GetLength + 1
  170. end if
  171. Next
  172. End Function
  173. ]]></xsl:script>
  174. <xsl:template match="/"><xsl:apply-templates select="//RESULTS"/><xsl:apply-templates select="//INSTANCE"/><xsl:eval no-entities="true" language="VBScript">DisplayValues(this)</xsl:eval></xsl:template>
  175. <xsl:template match="RESULTS"><xsl:eval no-entities="true" language="VBScript">CountResults(this)</xsl:eval></xsl:template>
  176. <xsl:template match="INSTANCE"><xsl:eval language="VBScript">GotInstance()</xsl:eval><xsl:apply-templates select="PROPERTY|PROPERTY.ARRAY|PROPERTY.REFERENCE"/></xsl:template>
  177. <xsl:template match="PROPERTY|PROPERTY.ARRAY|PROPERTY.REFERENCE"><xsl:eval no-entities="true" language="VBScript">GetValues(this)</xsl:eval></xsl:template>
  178. </xsl:stylesheet>