[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: XSL reading URL properties
How about just a teeny touch of non XSL/XML??? Here is the only way I have been able to do this: Three documents: (1) your XML, (2) your XSL, and (3) an HTML document containing only the following: <SCRIPT> var xslt = new ActiveXObject("Msxml2.XSLTemplate"); var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument"); var xslProc; xslDoc.async = false; xslDoc.resolveExternals = false; xslDoc.load("homepage_format.xsl"); xslt.stylesheet = xslDoc; var xmlDoc = new ActiveXObject("Msxml2.DOMDocument"); xmlDoc.async = false; xmlDoc.resolveExternals = false; xmlDoc.load("homepage_output.xml"); xslProc = xslt.createProcessor(); xslProc.input = xmlDoc; var temp = location.search; var temp_len = temp.length; xslProc.addParameter("unit_id", temp.substring(1,temp_len)); xslProc.transform(); document.write(xslProc.output); </SCRIPT> Call the HTML page like this: http://www.mypage.com/your.html?Smith Where "Smith" is the value you want to pass in. In the script shown above, you will change the XML and XSL file names and also change "unit_id" to a field name that works better for you. To read this, put the following at the top of your XSL: <?xml version="1.0" encoding="ISO-8859-1" ?> - <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:param name="unit_id" /> - <xsl:template match="PAGE"> - <html>........... Then when you want to use it, do something like: <xsl:for-each select="document($file_name)/PAGE/UNIT[UNIT_ID=$unit_id]"> And you will only get those rows from $file_name where UNIT_ID matches whatever is in the URL on the other side of the question mark. So the only non-XSL/XML code is in the HTML document. If there is another way, I'd love to know it too! Steve -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Jesse Ephraim Sent: Thursday, December 12, 2002 5:15 PM To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx Subject: XSL reading URL properties I have an unusual situation at work, and am hoping that somebody can help me. I have an XML file with data about various items, and an XSL file that reads it and prints it out. Easy enough. I need to have the XSL file read the data sent from an HTML form (by Post, Get, or something similar) and display it. It would be okay to pass properties in the actual URL, too. For example, if an HTML page has a form that takes your last name, I need that to be displayed at the top of the XML/XSL page. Here's the catch... No Javascript, no ASP, no JAVA, no scripting language of any kind, no extra software loaded onto the server, etc. It all has to be contained within the XML and XSL files. (I didn't make these rules up - in this case I'm just following orders). Any suggestions would be helpful and greatly appreciated. - Jesse XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|