ameliabob Posted October 31, 2008 Share Posted October 31, 2008 I am trying to get a function into an XSLT file and am having (I think) some syntax problems <xsl:if test="SignalsDir !='' " > <tr> <td> <input type="checkbox" onclick='DoProcessing(<xsl:value-of select="symbol"/>)' name="able" value="yes" /> Can I not do something like this?I am also trying to put something into an input box with code like this <td align="center"> <input type="text" /> <xsl:value-of select='SignalsQty'/></td> Link to comment Share on other sites More sharing options...
aalbetski Posted November 3, 2008 Share Posted November 3, 2008 try this<input type="checkbox" onclick="DoProcessing({symbol})" name="able" value="yes" /><input type="text" value="{SignalsQty}" /> the curly braces are intended for this usage Link to comment Share on other sites More sharing options...
ameliabob Posted November 6, 2008 Author Share Posted November 6, 2008 try this<input type="checkbox" onclick="DoProcessing({symbol})" name="able" value="yes" /><input type="text" value="{SignalsQty}" /> the curly braces are intended for this usageFor the most part it worked. That is the XSLT processor accepted it. However, when I went to the DoProcessing it took the {symbol} as a function.e.g.function DoProcessing(argument){alert("Show Argument " + argument);}<input type="checkbox" onclick="DoProcessing({symbol})" name="able" value="yes" />symbol is displayed as Test" The browser comes back with the response "Test is not defined"I didn't mean it to be defined just passed as a string.????? Link to comment Share on other sites More sharing options...
aalbetski Posted November 7, 2008 Share Posted November 7, 2008 to do what you want you will need to encase it in quotes<input type="checkbox" onclick="DoProcessing('{symbol}')" name="able" value="yes" />That should work Link to comment Share on other sites More sharing options...
ameliabob Posted November 7, 2008 Author Share Posted November 7, 2008 I tried the DoProcessing('{symbol}') and also DoProcessing({'symbol'}). The both came up with the "Test is not defined" message. Hmmm Link to comment Share on other sites More sharing options...
aalbetski Posted November 7, 2008 Share Posted November 7, 2008 show the generated markup Link to comment Share on other sites More sharing options...
ameliabob Posted November 7, 2008 Author Share Posted November 7, 2008 I am having trouble seeing this in the raw form. My view source only shows me the original document. Not the AJAx returned one. What is the best way to see this? Link to comment Share on other sites More sharing options...
aalbetski Posted November 7, 2008 Share Posted November 7, 2008 show me whats it is supposed to look like and the xml fragment where the data is Link to comment Share on other sites More sharing options...
ameliabob Posted November 9, 2008 Author Share Posted November 9, 2008 I have broken the code fragments into three pieces the part from the XSLT file, the part from the XML file and the code that puts the two together [b]code from $fromfile[/b]<xsl:for-each select="UserData/market/contract"><td> <input type="checkbox" onclick="SignalClicked({symbol})" name="able" value="yes" /> </xsl:for-each>[b]code from $xformation[/b]<?xml version="1.0"?><UserData> <market> <contract><symbol>CT8Z </symbol></contract></market></UserData>[b]transform code the echo returns to the browser[/b]$newxml = new DOMDocument;$newxml->load($fromFile);$newxsl = new DOMDocument;$newxsl->load( $xFormation);$process = new XSLTProcessor;$process->importStyleSheet($newxsl);echo $process->transformToXML($newxml); I don't know how to show your the raw transformation Link to comment Share on other sites More sharing options...
aalbetski Posted November 10, 2008 Share Posted November 10, 2008 see below comments Link to comment Share on other sites More sharing options...
aalbetski Posted November 10, 2008 Share Posted November 10, 2008 I don't know enough PHP to determine if your code is overwriting the function. Here is a complete page using XML data islands for both the source XML and the XSLT. If uses MSXML 6.0 but it does work by writing to the innerHTML of a div. The XSLT works fine (which was the original question) and the event fires. I'm afraid I'm can't help with the PHP code <html> <head> <xml id="xmlSource"> <UserData> <market> <contract><symbol>CT8Z </symbol></contract> </market> </UserData> </xml> <xml id="xslStyle"> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" /> <xsl:template match="/"> <xsl:for-each select="//contract"> <input type="checkbox" onclick="DoProcessing('{symbol}')" name="able" value="yes" /> </xsl:for-each> </xsl:template> </xsl:stylesheet> </xml> <script type="text/javascript"> function loadXML() { var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.6.0") xmlDoc.async=false; xmlDoc.loadXML(xmlSource.xml); var xslSource = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.6.0") xslSource.async=false; xslSource.loadXML(xslStyle.xml); xslSource.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'") var objTransformer = new ActiveXObject("Msxml2.XSLTemplate.6.0") objTransformer.stylesheet = xslSource.documentElement var objProcessor = objTransformer.createProcessor() objProcessor.input = xmlDoc objProcessor.transform() //document.write(objProcessor.output) document.getElementById("content").innerHTML = objProcessor.output } function DoProcessing(value) { alert(value) } </script> </head> <body onload="loadXML()"> <div id="content"></div> </body></html> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.