I have the following xsl template loop (recursive) which calls a VBScript function that takes one parameter which represents the physical hard drive number and retrieves drive information:
<xsl:template name="for.loop.Drives">
<xsl:param name="i" select ="0" />
<xsl:param name="count" />
<!--begin_: Line_by_Line_Output -->
<xsl:if test="$i <= $count">
<xsl:value-of select="nunit2report2:GetDiskDrives($i)"/>
</xsl:if>
<!--begin_: RepeatTheLoopUntilFinished-->
<xsl:if test="$i <= $count">
<xsl:call-template name="for.loop.Drives">
<xsl:with-param name="i">
<xsl:value-of select="$i + 1"/>
</xsl:with-param>
<xsl:with-param name="count">
<xsl:value-of select="$count"/>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
The VBScript function (which I verified works):
Function GetDiskDrives(drivenumber)
strComputer = "."
objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
colItems = objWMIService.ExecQuery("Select * from Win32_DiskDrive")
'For Each objItem in colItems
DiskDriveInfo = DiskDriveInfo & "Name: " & colItems.ItemIndex(drivenumber).Name & _
" -- Model: " & colItems.ItemIndex(drivenumber).Model & _
" -- Status: " & colItems.ItemIndex(drivenumber).Status & _
" -- Size: " & Int(colItems.ItemIndex(drivenumber).Size /(1073741824)) & " GB" & _
" -- Number of Partitions: " & colItems.ItemIndex(drivenumber).Partitions
'Next
GetDiskDrives = DiskDriveInfo
End Function
The error returned is a type mismatch. It has to do with the $i passed in to the function:
<xsl:if test="$i <= $count">
<xsl:value-of select="nunit2report2:GetDiskDrives($i)"/>
</xsl:if>
When I do this, it works, but I’m explicitly passing in 1.
<xsl:if test="$i <= $count">
<xsl:value-of select="nunit2report2:GetDiskDrives(1)"/>
</xsl:if>
I tried converting the passed in $i to an integer in the VBScript using
drivenum = CInt(drivenumber)
but the cast above returns the following error:
System.InvalidCastException: Conversion from type 'XPathDocumentNavigator' to type 'Integer' is not valid.
Anyone know how I can get this call right? I’m using xslt 1.0
Have you tried: