This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
using ancestorChildNumber in VBScript
- To: "'XSL Mulberry List'" <XSL-List at mulberrytech dot com>
- Subject: using ancestorChildNumber in VBScript
- From: "Newman, Todd" <ToddNewman at TDWaterhouse dot com>
- Date: Mon, 20 Nov 2000 14:32:49 -0500
- Reply-To: xsl-list at mulberrytech dot com
Hi all,
Count me completely baffled. I did some work with XML/XSL using the IE5
version of MSXML. Now, I'm trying to convert my pages to MSXML 3.0 and I'm
going a bit nuts. Here's where I came from...
Partial XML Source
========================
<XML>
<Account>
<Holding>
<AccountNumber>123456789</AccountNumber>
<AccountType>1</AccountType>
<Symbol>ALL</Symbol>
<SecurityDescription>ALLSTATE CORP</SecurityDescription>
<CurrentQuantity>2000</CurrentQuantity>
<PreviousQuantity>2000</PreviousQuantity>
<PreviousClosePrice>60</PreviousClosePrice>
<PreviousMarketValue>120000</PreviousMarketValue>
<Price></Price>
</Holding>
<Holding>
...
</Holding>
</Account>
</XML>
========================
and here's part of the *old* XSL Source
========================
<xsl:template match="Symbol">
<a><xsl:attribute
name="href"><xsl:eval>SymbolHref(me)</xsl:eval></xsl:attribute>
<xsl:value-of select="."/></a>
</xsl:template>
<xsl:script xmlns:xsl="http://www.w3.org/TR/WD-xsl"
language="VBScript"><![CDATA[
function SymbolHref(e)
SymbolHref = "DetailScreen.asp?idx=" &
ancestorChildNumber("Holding",e) - 1
end function
]]></xsl:script>
========================
As I said, that worked fine. ancestorChildNumber would back up the tree
until it got to "Holding" and return the index of that node relative to its
parent. I subtracted 1 because I wanted the index to be zero-based. Trying
to do things the new way, I can't get the SymbolHref function to work.
Here's part of the *new* XSL Source
========================
<msxsl:script language="VBScript" implements-prefix="user"><![CDATA[
function SymbolHref(nodelist)
Dim nodeRef
set nodeRef = nodelist.nextNode()
SymbolHref = "DetailScreen.asp?idx=" &
ancestorChildNumber("Holding", nodeRef) - 1
set nodeRef = Nothing
end function
]]></msxsl:script>
<xsl:template match="Symbol">
<td><a><xsl:attribute name="href"><xsl:value-of
select="user:SymbolHref(.)"/></xsl:attribute>
<xsl:value-of select="."/></a></td>
</xsl:template>
========================
First of all, I really do need to convert to the "new" way so that I can use
xsl:param and xsl:include. The error I get is a 'Type mismatch' on the 2nd
parameter of ancestorChildNumber. Here are some things I've tried and their
results.
SymbolHref = "DetailScreen.asp?idx=" &
ancestorChildNumber("Holding", nodelist.nextNode()) - 1
Result: Same 'Type mismatch' error.
SymbolHref = "Hi there"
Result: No error, returns the string
SymbolHref = nodelist.nextNode().nodeTypedValue
Result: No error, returns the value I would expect
set nodeRef = nodelist.nextNode()
SymbolHref = nodeRef.nodeTypedValue
Result: No error, same as previous
So, it looks like nodelist.nextNode() does return a reference to the current
node since I can get to its .nodeTypedValue property. (or its .xml property
etc.) But when I try to pass this reference to ancestorChildNumber, I get
the error as mentioned above.
Can anyone help me find what to pass in?
TIA,
Todd
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list