RE: [xsl] RE: How to pass VBScript variable in XSL code

Subject: RE: [xsl] RE: How to pass VBScript variable in XSL code
From: "Nistala, Anu" <anistala@xxxxxxxxx>
Date: Wed, 14 Nov 2007 11:11:14 -0600
Great Help Steve. I implemented that and I got what I am looking for :)
Thanks a mill!

Thanks!
Anu Nistala
anistala@xxxxxxxxx
512 248 4535 (office)
Nodal Integration Test Automation
Electric Reliability Council of Texas, Inc.


-----Original Message-----
From: Steve [mailto:subsume@xxxxxxxxx]
Sent: Wednesday, November 14, 2007 10:04 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] RE: How to pass VBScript variable in XSL code

When I do something similar, I simply print out all the descriptions
into hidden divs with a unique ID. Then, of course, have the Script
choose which div based on the select value.

-Steve

On Nov 14, 2007 10:09 AM, Nistala, Anu <anistala@xxxxxxxxx> wrote:
> Hello,
>
> I have a dropdown list populated from XML. Now, based on the selection
on the dropdown the onclick event is expected to display the description
of the function. The idea is to get the index of the selected list item
and display the corresponding description node from the XML. I have
tried several ways to pass the value to the xsl tags. I tried
Concatenating the string "<xsl:value-of select=""functiontitle/funcdef["
& i & "]/funcdesc"" />". This did not work (obviously... xsl didn't like
it).
>
> I also tried to define a namespace and declare a variable and trying
to solve it by passing a variable to it. I don't know what I maybe
missing, cause I am getting an error "Namespace
'http://www.w3.org/XML/1998/namespace' does not contain any functions."
>
> I would really appreciate any help on this one! Thanks in Advance!
>
> The original XSL Goes like this:
>
> <?xml version='1.0'?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>
> <xsl:template name="dropdown-button">
>  <h2>User Defined Functions Dropdown List</h2>
>
>  < script language="VBScript" >
>  function SetVal()
>  for i=1 to 6
>   if UCAse(document.getElementById(i).selected) = "TRUE" then
>
document.form1.functionName.value=document.getElementById(i).innerHTML
>  document.form1.functiondescription.value = "<xsl:value-of
select="functiontitle/funcdef[i]/funcdesc" />"
>   Exit For
>   End if
>  Next
>  End function
>  </msxsl:script>
>
>  <form name="form1">
>  <table border = "0">
>  <tr>
>  <td>
>  <b>Select a function</b>
>  </td>
>  <td>
>  <select name="functionList" id="first">
>
>  <xsl:variable name="my-var">
>   <xsl:value-of select = "1"/>
>  </xsl:variable>
>
>   <xsl:for-each select="functiontitle/funcdef">
>
>   <xsl:variable name="funcid">
>   <xsl:value-of select = "id"/>
>   </xsl:variable>
>   <option id="{$funcid}">
>   <xsl:value-of select="funcname"/>
>  </option>
>
>  </xsl:for-each>
>
>  </select>
>  </td>
>  <td>
>  <input id="second" name="Details" type ="button" value="Click here
for Details!" onclick="SetVal()"/>
>  </td>
>  </tr>
>  <table id="third" name="hiddentable" border="1">
>  <div>
>  <tr>
>   <td>
>   <input id="fourth" type="text" name="functionName" />
>   </td>
>   <td>
>   <input id="fifth" type="text" name="functiondescription" />
>   </td>
>  </tr>
>  </div>
>  </table>
>  </table>
>  </form>
>  </xsl:template>
>
>  <xsl:template match="/">
>  <html>
>  <body>
>
>  <xsl:call-template name="dropdown-button" />
>
>  </body>
>  </html>
>  </xsl:template>
>
> </xsl:stylesheet>
>
> The XSL with Namespace and variable goes like this:
>
> <?xml version='1.0'?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> xmlns:msxsl="urn:schemas-microsoft-com:xslt"
> xmlns:vb_user="http://www.w3.org/XML/1998/namespace";>
>
>  <xsl:template name="dropdown-button">
>  <h2>User Defined Functions Dropdown List</h2>
>
>  <msxsl:script language="VBScript" implements-prefix="vb_user">
>
>  function SetVal()
>
>  for i=1 to 6
>
>   if UCAse(document.getElementById(i).selected) = "TRUE" then
>
>
document.form1.functionName.value=document.getElementById(i).innerHTML
>
>   Set SetVal = i
>
>   Exit For
>
>   End if
>
>  Next
>
>
>  End function
>  </msxsl:script>
>
>  <form name="form1">
>  <table border = "0">
>  <tr>
>  <td>
>  <b>Select a function</b>
>  </td>
>  <td>
>  <select name="functionList" id="first">
>
>  <xsl:variable name="my-var">
>   <xsl:value-of select = "1"/>
>  </xsl:variable>
>
>   <xsl:for-each select="functiontitle/funcdef">
>   <xsl:variable name="funcid">
>   <xsl:value-of select = "id"/>
>   </xsl:variable>
>   <option id="{$funcid}">
>  <xsl:value-of select="funcname"/>
>  </option>
>  </xsl:for-each>
>
>  </select>
>  </td>
>  <td>
>  <input id="second" name="Details" type ="button" value="Click here
for Details!" onclick="SetVal()"/>
>
>   <xsl:variable name="test">
>   <xsl:value-of select="vb_user:SetVal()"/>
>  </xsl:variable>
>
>  </td>
>  </tr>
>  <table id="third" name="hiddentable" border="1">
>  <div>
>  <tr>
>   <td>
>   <input id="fourth" type="text" name="functionName" />
>   </td>
>
>   <td>
>   <input id="fifth" type="text" name="functiondescription"
value="{$test}" />
>   </td>
>  </tr>
>  </div>
>  </table>
>  </table>
>  </form>
>  </xsl:template>
> </xsl:stylesheet>
>
>
> The XML is like this:
>
> <?xml-stylesheet type="text/xsl" href="todropdown.xsl"?>
>
> <functiontitle>
>
>  <funcdef >
>  <id>1</id>
>  <funcname >flNVGLogin</funcname>
>  <funcdesc >This function logs into CMM app</funcdesc>
>  </funcdef>
>
>  <funcdef >
>  <id>2</id>
>  <funcname >flVLDLogin</funcname>
>  <funcdesc >This validates login page</funcdesc>
>  </funcdef>
>
>  <funcdef >
>  <id>3</id>
>  <funcname >flNVGCloseBrowser</funcname>
>  <funcdesc >This function closes CMM app</funcdesc>
>  </funcdef>
>
>  <funcdef >
>  <id>4</id>
>  <funcname >flVLDCloseBrowser</funcname>
>  <funcdesc >This function navigates and closes the browser</funcdesc>
>  </funcdef>
>
>  <funcdef >
>  <id>5</id>
>  <funcname >flNVGPopup</funcname>
>  <funcdesc >This function navigates thru the popup menu</funcdesc>
>  </funcdef>
>
>  <funcdef >
>  <id>6</id>
>  <funcname >flVLDPopup</funcname>
>  <funcdesc >This function validates the popup menu items</funcdesc>
>  </funcdef>
>
> </functiontitle>
>
> Thanks!
> Anu Nistala
> anistala@xxxxxxxxx
> 512 248 4535 (office)
> Nodal Integration Test Automation
> Electric Reliability Council of Texas, Inc.

Current Thread