You can solicit the user input in whatever fashion you desire, a winform, webform, etc.. You would pass that information into the stylesheet as a parameter. I have created a complete working example using javascript and XMLDOM (with IE6.0). You will need to modify based on your enviroment (.NET, ASP, etc..)Sample XML (price.xml)
<catalog> <cd> <name>CD1</name> <price>10</price> </cd> <cd> <name>CD2</name> <price>10</price> </cd> <cd> <name>CD3</name> <price>15</price> </cd> <cd> <name>CD4</name> <price>15</price> </cd> <cd> <name>CD5</name> <price>12</price> </cd></catalog>
Sample XSL (price.xsl)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html"/> <xsl:param name="price" /> <xsl:template match="/"> <xsl:for-each select="catalog/cd"> <xsl:if test="price = $price"> <xsl:value-of select="name" /><br/> </xsl:if> </xsl:for-each> </xsl:template></xsl:stylesheet>
HTML Page that performs transform. Note the value of '10' being passed into the TransformXML() function. This is where you would pass the value to the transformer. How it gets there is up to you.price.html
<html> <body onLoad="InitPage()"> <div id="display"></div> </body> <script> function InitPage() { document.getElementById("display").innerHTML = TransformXML(10) } function TransformXML(price) { var xmlSource = new ActiveXObject("Msxml2.DOMDocument.4.0") var xslStyle = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0") xmlSource.async = false xslStyle.async = false xmlSource.load("price.xml") xslStyle.load("price.xsl") xslStyle.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'") var objTransformer = new ActiveXObject("Msxml2.XSLTemplate.4.0") objTransformer.stylesheet = xslStyle.documentElement var objProcessor = objTransformer.createProcessor() objProcessor.addParameter("price",price,"") objProcessor.input = xmlSource objProcessor.transform() return objProcessor.output } </script></html>