By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,948 Members | 1,559 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,948 IT Pros & Developers. It's quick & easy.

How to use JavaScript array in xsl

P: 25
I want to use a array created in javascript whoes value is drived from a xml file by DOM.

now i want to use that array to creat the google chart by calling that array value in the imge source path.

Expand|Select|Wrap|Line Numbers
  1. var valueArray = new Array();
  2. var myId = document.getElementById("GraphThisTable");
  3. var rows = myId.getElementsByTagName("tr");
  4. for(i = 1; i != rows.length; i++)
  5. {
  6. var cols = rows[i].getElementsByTagName("td");
  7. valueArray[i - 1] = cols[1].innerHTML;
  8. }
  9. alert(valueArray);
now want to use the "valueArray" in xsl to set image attribute

Expand|Select|Wrap|Line Numbers
  1. <img><xsl:attribute name="src">;chd=t:1,1,1,3,1,2,2,2&amp;chs=250x100&amp;chl=2001|2003|2004|2000|2002|3001|3002|3003</xsl:attribute></img>
Thus insted of "chd=t:1,1,1,3,1,2,2,2" i want to use "chd=t:$valueArray"

Can any one help me out how to write the xsl for the same using javascript variable in xsl
Dec 11 '08 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 5K+
P: 8,639
if you want to pass a simple type value (like string or number) to xsl, you can use parameters (<xsl:param>) for that, but I'm not aware that complex types (like arrays or objects) can be passed. see Setting Parameters – MDC.

on the other hand, what is the xml file your xslt is applied to? if there is currently none you may condider transforming your array into xml and let the xslt work on that, you don't even need parameters then. or if there is already one, import the transformed array via the document() function in xslt.


PS: ask a mod to move this thread to the answers section
Dec 11 '08 #2

Expert Mod 15k+
P: 16,027
rupak, you posted this in the insights section rather than the answers forum section. I've moved it across for you.

Also, remember to use code tags when posting code, not quote tags. Thanks.

Dec 11 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.