Solved

Parameters in XML

Posted on 2002-06-13
4
278 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
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
b1xml2 earned 50 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now