[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

using ancestorChildNumber in VBScript

Subject: using ancestorChildNumber in VBScript
From: "Newman, Todd" <ToddNewman@xxxxxxxxxxxxxxxx>
Date: Mon, 20 Nov 2000 14:32:49 -0500
nextnode vbscript
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.