?
Solved

Parameters in XML

Posted on 2002-06-13
4
Medium Priority
?
285 Views
Last Modified: 2008-02-20
Hi,
On a web page, I have a menu.  Each option call a xml file but I want to pass a parameter to know witch option is selected.  I can I do that.
Example : Option 1 call the XSLT with parameter "1"
          Option 2 call the XSLT with parameter "2"
          Etc.  
I know the instruction <xsl:param name='year'/>  but how the xslt will know the value of the parameter ?
Thank you very much
0
Comment
Question by:frdep
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
b1xml2 earned 200 total points
ID: 7075993
excellent question! this is how it is done with scripted transforms and MSXML3+

<html>
<head>
<title>Using the IXSLProcessor Object</title>
<script language="javascript">
//using MSXML3
var oXML = new ActiveXObject("Msxml2.DOMDocument.3.0");
var oXSLT = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.3.0");
var oTemplate = new ActiveXObject("Msxml2.XSLTemplate.3.0");
oXML.async = oXSLT.async = false;
oXML.load("data.xml");
oXSLT.load("data.xsl");

//assign the stylesheet to the IXSLTemplate stylesheet object

oTemplate.stylesheet = oXSLT;

//now you can remove the XSLT Tree to save resources
delete oXSLT; oXSLT = null; CollectGarbage();

//create the IXSLProcessor now
var oProc = oTemplate.createProcessor();
oProc.input = oXML;

//we are now ready to do the stuff
window.onload = init;
function init() {
 //perform transformation
 oProc.transform();
 //get the transformed stream
 document.all.data.innerHTML = oProc.output;
}

function setAndTransform(vtName,vtValue) {
 oProc.addParameter("" + vtName, "" + vtValue);
 oProc.transform();
 document.all.data.innerHTML = oProc.output;
}

</script>
</head>
<body>
<input type="radio" name="vendor" value="1"
 onclick="setAndTransform('year',this.value);">Microsoft<br>
<input type="radio" name="vendor" value="2"
 onclick="setAndTransform('year',this.value);">IBM<br>
<div id="data"></div>
</body>
</html>

Notes
=====
1. MSIE 5+ Only
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 7076003
the addParameter of the IXSLProcessor allows you to pass external values to the parameter inside the XSLT seamlessly.

addParameter(<name>,<value>);
0

Featured Post

TCP/IP Network Protocol Cheat Sheet

TCP/IP is a set of network protocols which is best known for connecting the machines that make up the Internet. The truth is that TCP/IP is one of the oldest network protocols and its survival is mainly based on its simplicity and universality.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question