<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Setting XSL Parameters from Javascript in AJAXSLT</title>
	<atom:link href="http://www.eahanson.com/2005/10/23/setting-xsl-parameters-from-javascript-in-ajaxslt/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.eahanson.com/2005/10/23/setting-xsl-parameters-from-javascript-in-ajaxslt/</link>
	<description>My weblog</description>
	<lastBuildDate>Tue, 27 Jul 2010 19:36:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Matt</title>
		<link>http://www.eahanson.com/2005/10/23/setting-xsl-parameters-from-javascript-in-ajaxslt/comment-page-1/#comment-2332</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Wed, 24 Jan 2007 16:48:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=6#comment-2332</guid>
		<description>Hi Erik -

I see you have been working with ajaxslt for quite a while.  That&#039;s good, because I&#039;m just starting (although I&#039;m not a newbie coder).

I am trying to pass a value into my xsl via javascript, as you have shown above, but I can&#039;t seem to get it to work.  Please take a look at what I have and let me know if you can spot the error.

Any assistance you (or anyone else reading this) can offer, would be very much appreciated.

Thanks.
- Matt

javascript:
function transform(strXML, strXSL) {
  // strXML &amp; strXSL are populated via ajax calls to the files,
  // so they are just text.

  var myXSL = xmlParse(strXSL);

  // putHere is defined in the body as
  // 
  var myNode = document.getElementById(&#039;putHere&#039;);

  var myContext = new ExprContext(strXML);
  myContext.setVariable(&quot;CURRENT_PAGE&quot;, new StringValue(&quot;TWO&quot;));

  xsltProcessContext(myContext, strXSL, myNode);
}


xsl content:

1

CURRENT_PAGE: 



As a side note, the following javascript works, but I can&#039;t figure out how to pass a param into the xsl.
function transform2(strXML, strXSL) {
  var xml  = xmlParse(strXML);
  var xslt = xmlParse(strXSL);
  var html = xsltProcess(xml, xslt);
  document.getElementById(&#039;putHere&#039;).innerHTML = html;
}

Within my firefox error console I see the following error:
&quot;template.nodeName has no properties&quot;

This blog seems to be about a year old, is there an updated way to do this now?

Thanks again.
- Matt</description>
		<content:encoded><![CDATA[<p>Hi Erik -</p>
<p>I see you have been working with ajaxslt for quite a while.  That&#8217;s good, because I&#8217;m just starting (although I&#8217;m not a newbie coder).</p>
<p>I am trying to pass a value into my xsl via javascript, as you have shown above, but I can&#8217;t seem to get it to work.  Please take a look at what I have and let me know if you can spot the error.</p>
<p>Any assistance you (or anyone else reading this) can offer, would be very much appreciated.</p>
<p>Thanks.<br />
- Matt</p>
<p>javascript:<br />
function transform(strXML, strXSL) {<br />
  // strXML &amp; strXSL are populated via ajax calls to the files,<br />
  // so they are just text.</p>
<p>  var myXSL = xmlParse(strXSL);</p>
<p>  // putHere is defined in the body as<br />
  //<br />
  var myNode = document.getElementById(&#8216;putHere&#8217;);</p>
<p>  var myContext = new ExprContext(strXML);<br />
  myContext.setVariable(&#8220;CURRENT_PAGE&#8221;, new StringValue(&#8220;TWO&#8221;));</p>
<p>  xsltProcessContext(myContext, strXSL, myNode);<br />
}</p>
<p>xsl content:</p>
<p>1</p>
<p>CURRENT_PAGE: </p>
<p>As a side note, the following javascript works, but I can&#8217;t figure out how to pass a param into the xsl.<br />
function transform2(strXML, strXSL) {<br />
  var xml  = xmlParse(strXML);<br />
  var xslt = xmlParse(strXSL);<br />
  var html = xsltProcess(xml, xslt);<br />
  document.getElementById(&#8216;putHere&#8217;).innerHTML = html;<br />
}</p>
<p>Within my firefox error console I see the following error:<br />
&#8220;template.nodeName has no properties&#8221;</p>
<p>This blog seems to be about a year old, is there an updated way to do this now?</p>
<p>Thanks again.<br />
- Matt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik</title>
		<link>http://www.eahanson.com/2005/10/23/setting-xsl-parameters-from-javascript-in-ajaxslt/comment-page-1/#comment-1296</link>
		<dc:creator>Erik</dc:creator>
		<pubDate>Tue, 26 Sep 2006 20:51:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=6#comment-1296</guid>
		<description>Hi Jeremy,

I&#039;m sorry for being so dense but I can&#039;t quite figure out what you&#039;re asking. Can you perhaps try re-stating your question or re-explaining what you&#039;re trying to accomplish?</description>
		<content:encoded><![CDATA[<p>Hi Jeremy,</p>
<p>I&#8217;m sorry for being so dense but I can&#8217;t quite figure out what you&#8217;re asking. Can you perhaps try re-stating your question or re-explaining what you&#8217;re trying to accomplish?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeremy Patterson</title>
		<link>http://www.eahanson.com/2005/10/23/setting-xsl-parameters-from-javascript-in-ajaxslt/comment-page-1/#comment-1295</link>
		<dc:creator>Jeremy Patterson</dc:creator>
		<pubDate>Tue, 26 Sep 2006 15:47:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=6#comment-1295</guid>
		<description>Eric, 

Thanks for the tutorial, I need a bit of assistance though. I am trying to pass values into an xml page through the url. I defaulted a parameter strParam = &#039;None&#039;. When I click a link in the html, I want it to load a parameter, which will make the page dynamic based on the conditions I set in the xslt.

www.webpage.com/myXML.xml?strParam=SomeValue

would you have some code on how to perform this. I tried Sarissa, but couldn&#039;t figure it out. I think your implementation might work, just need a little more detail. I have very limited xslt background and none in javascript. I am using this format because I have limited resources and I need the site to be dynamic. I know the xslt works because I can compile it against saxon and the logic will work.

You are basically doing the same thing here:
http://www.eahanson.com/weblog/?p=4

I&#039;m probably missing something that was already explained. Would you have an example javascript function, that sets the parameter? How would I call the javascript to trigger the parameter change, when the page reloads?

Thank you for your assistance - Jeremy</description>
		<content:encoded><![CDATA[<p>Eric, </p>
<p>Thanks for the tutorial, I need a bit of assistance though. I am trying to pass values into an xml page through the url. I defaulted a parameter strParam = &#8216;None&#8217;. When I click a link in the html, I want it to load a parameter, which will make the page dynamic based on the conditions I set in the xslt.</p>
<p><a href="http://www.webpage.com/myXML.xml?strParam=SomeValue" rel="nofollow">http://www.webpage.com/myXML.xml?strParam=SomeValue</a></p>
<p>would you have some code on how to perform this. I tried Sarissa, but couldn&#8217;t figure it out. I think your implementation might work, just need a little more detail. I have very limited xslt background and none in javascript. I am using this format because I have limited resources and I need the site to be dynamic. I know the xslt works because I can compile it against saxon and the logic will work.</p>
<p>You are basically doing the same thing here:<br />
<a href="http://www.eahanson.com/weblog/?p=4" rel="nofollow">http://www.eahanson.com/weblog/?p=4</a></p>
<p>I&#8217;m probably missing something that was already explained. Would you have an example javascript function, that sets the parameter? How would I call the javascript to trigger the parameter change, when the page reloads?</p>
<p>Thank you for your assistance &#8211; Jeremy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Bruce</title>
		<link>http://www.eahanson.com/2005/10/23/setting-xsl-parameters-from-javascript-in-ajaxslt/comment-page-1/#comment-727</link>
		<dc:creator>Andrew Bruce</dc:creator>
		<pubDate>Wed, 28 Jun 2006 15:31:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=6#comment-727</guid>
		<description>After some fiddling, and a read of some api-like documentation I found at http://mocha.ch/OpenMocha/Handbook/Combined%20Browser%20Reference/ , I found that getting the result of a transformation from a xsltProcessContext call (rather than a straight xsltProcess call, which requires XSLT in a DOM node), can be done like so:

var node = document.createElement(&#039;output&#039;);
xsltProcessContext(context, xsl, node);
var output = xmlText(node);

this is seriously tricky without documentation, guys...</description>
		<content:encoded><![CDATA[<p>After some fiddling, and a read of some api-like documentation I found at <a href="http://mocha.ch/OpenMocha/Handbook/Combined%20Browser%20Reference/" rel="nofollow">http://mocha.ch/OpenMocha/Handbook/Combined%20Browser%20Reference/</a> , I found that getting the result of a transformation from a xsltProcessContext call (rather than a straight xsltProcess call, which requires XSLT in a DOM node), can be done like so:</p>
<p>var node = document.createElement(&#8216;output&#8217;);<br />
xsltProcessContext(context, xsl, node);<br />
var output = xmlText(node);</p>
<p>this is seriously tricky without documentation, guys&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Will</title>
		<link>http://www.eahanson.com/2005/10/23/setting-xsl-parameters-from-javascript-in-ajaxslt/comment-page-1/#comment-46</link>
		<dc:creator>Will</dc:creator>
		<pubDate>Tue, 17 Jan 2006 14:43:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=6#comment-46</guid>
		<description>It works!!!!
But in my case it was :
myContext.setVariable(&quot;theParam&quot;,new NumberValue(theValue));
You know what, Erik? you are fantastic.

in xpath.js :
&quot;The four types are:
   StringValue
   NumberValue
   BooleanValue
   NodeSetValue&quot;</description>
		<content:encoded><![CDATA[<p>It works!!!!<br />
But in my case it was :<br />
myContext.setVariable(&#8220;theParam&#8221;,new NumberValue(theValue));<br />
You know what, Erik? you are fantastic.</p>
<p>in xpath.js :<br />
&#8220;The four types are:<br />
   StringValue<br />
   NumberValue<br />
   BooleanValue<br />
   NodeSetValue&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik</title>
		<link>http://www.eahanson.com/2005/10/23/setting-xsl-parameters-from-javascript-in-ajaxslt/comment-page-1/#comment-45</link>
		<dc:creator>Erik</dc:creator>
		<pubDate>Mon, 16 Jan 2006 17:05:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=6#comment-45</guid>
		<description>It&#039;s the node that you want to put the result of the XML+XSL rendering into. See http://www.eahanson.com/weblog/?p=4 for more info (I called it &quot;myNode&quot; in that one).</description>
		<content:encoded><![CDATA[<p>It&#8217;s the node that you want to put the result of the XML+XSL rendering into. See <a href="http://www.eahanson.com/weblog/?p=4" rel="nofollow">http://www.eahanson.com/weblog/?p=4</a> for more info (I called it &#8220;myNode&#8221; in that one).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Will</title>
		<link>http://www.eahanson.com/2005/10/23/setting-xsl-parameters-from-javascript-in-ajaxslt/comment-page-1/#comment-44</link>
		<dc:creator>Will</dc:creator>
		<pubDate>Mon, 16 Jan 2006 10:07:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=6#comment-44</guid>
		<description>what do you call &quot;myRootElement&quot; in
&quot;xsltProcessContext(myContext, myXsl, myRootElement);&quot;?</description>
		<content:encoded><![CDATA[<p>what do you call &#8220;myRootElement&#8221; in<br />
&#8220;xsltProcessContext(myContext, myXsl, myRootElement);&#8221;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik</title>
		<link>http://www.eahanson.com/2005/10/23/setting-xsl-parameters-from-javascript-in-ajaxslt/comment-page-1/#comment-43</link>
		<dc:creator>Erik</dc:creator>
		<pubDate>Mon, 16 Jan 2006 05:09:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=6#comment-43</guid>
		<description>var theValue = document.getElementByID(&quot;mySelect&quot;).value;
myContext.setVariable(&quot;theValue&quot;, theValue);</description>
		<content:encoded><![CDATA[<p>var theValue = document.getElementByID(&#8220;mySelect&#8221;).value;<br />
myContext.setVariable(&#8220;theValue&#8221;, theValue);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Will</title>
		<link>http://www.eahanson.com/2005/10/23/setting-xsl-parameters-from-javascript-in-ajaxslt/comment-page-1/#comment-41</link>
		<dc:creator>Will</dc:creator>
		<pubDate>Sat, 14 Jan 2006 19:51:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=6#comment-41</guid>
		<description>oupps oupps oupps
I have a form whith a select and a submit in a xhtml page.
each options of the select have a value (1, 2, 3, 4, 5...)
the submit do two XHR (one for the xml and a second for xsl).
how could you pass the value of the selected option in xhtml to the xsl.
like this : 
xsl:\template match=&quot;/&quot;
xsl:apply-templates select=&quot;page/message/things/thing[$theValue]&quot;/
/xsl:template

xsl:template match=&quot;page/message/things/thing[$theValue]&quot;
...
/xsl:template</description>
		<content:encoded><![CDATA[<p>oupps oupps oupps<br />
I have a form whith a select and a submit in a xhtml page.<br />
each options of the select have a value (1, 2, 3, 4, 5&#8230;)<br />
the submit do two XHR (one for the xml and a second for xsl).<br />
how could you pass the value of the selected option in xhtml to the xsl.<br />
like this :<br />
xsl:\template match=&#8221;/&#8221;<br />
xsl:apply-templates select=&#8221;page/message/things/thing[$theValue]&#8220;/<br />
/xsl:template</p>
<p>xsl:template match=&#8221;page/message/things/thing[$theValue]&#8221;<br />
&#8230;<br />
/xsl:template</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik</title>
		<link>http://www.eahanson.com/2005/10/23/setting-xsl-parameters-from-javascript-in-ajaxslt/comment-page-1/#comment-38</link>
		<dc:creator>Erik</dc:creator>
		<pubDate>Sat, 14 Jan 2006 17:46:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=6#comment-38</guid>
		<description>The site that I used this code in isn&#039;t live yet. But is the example code in this post not enough? Do you have a specific question I might be able to answer?</description>
		<content:encoded><![CDATA[<p>The site that I used this code in isn&#8217;t live yet. But is the example code in this post not enough? Do you have a specific question I might be able to answer?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Will</title>
		<link>http://www.eahanson.com/2005/10/23/setting-xsl-parameters-from-javascript-in-ajaxslt/comment-page-1/#comment-37</link>
		<dc:creator>Will</dc:creator>
		<pubDate>Sat, 14 Jan 2006 15:59:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=6#comment-37</guid>
		<description>please, do you have an example of this online ?
Thanks for your  2 posts on AJAXSLT.</description>
		<content:encoded><![CDATA[<p>please, do you have an example of this online ?<br />
Thanks for your  2 posts on AJAXSLT.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
