Cannot run VBscript functions under XSLT

I need to add a snippet of VBscript to an XSLT and can't seem to get any functions to work. Just about anything I do returns the error 'Wrong number of arguments or improper property assignment. This is intended to run from a VB6 app and is pre .Net.

Breaking it down, the following exhibits the problem. Any attempt to concatenate (or perform any other function fails).
_/_/_/ MY XSLT... _/_/_/

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet 
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:msxsl='urn:schemas-microsoft-com:xslt'
  xmlns:testingVB='urn:touch-base.com'
  exclude-result-prefixes="msxsl testingVB">
  <msxsl:script implements-prefix='testingVB' language='VBscript'>
  <![CDATA[
Function MyTest(MyStr) 
   Set MyTest = MyStr & " jumps over the lazy dog"
End Function
  ]]>
  </msxsl:script>

  <xsl:output method="xml" indent="yes" encoding="utf-8" omit-xml-declaration="no"/>
	<xsl:template match="/">
			<Items>
				<Item><xsl:value-of select="testingVB:MyTest(Items/Item)"/></Item>
			</Items>
	</xsl:template>
</xsl:stylesheet>

_/_/_/ MY XML... _/_/_/

<?xml version="1.0"?>
   <Items>
      <Item>The quick brown fox</Item>
   </Items>

Open in new window

LVL 1
Trevor HelpsTechnical DirectorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zc2Commented:
MyStr is not a string, it's a nodeset (a collection).
Each item is an XMLElement, so you need to use its .text property to access to the data:
Function MyTest(MyStr) 
   MyTest = MyStr.item(0).text & " jumps over the lazy dog"
End Function

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gertone (Geert Bormans)Information ArchitectCommented:
you need to cast the node to a string prior to passing it to the function
(note I added the string() function in the XSLT)

<Item><xsl:value-of select="testingVB:MyTest(string(Items/Item))"/></Item>

That is a classic mistake:
Items/Item is a nodeset, not a string

you should also remove the "Set", it doesn't serve anything and the microsoft scripting engine choques on it

      Function MyTest(MyStr)
            MyTest = MyStr + " jumps over the lazy dog"
      End Function


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.