kwilliams Posted April 21, 2008 Share Posted April 21, 2008 I have an XSLT page that pulls a variable from a JavaScript document. This is what the code looks like: JavaScript //Generic variablesvar subject = "?Subject=Website Comment/Question";var mailto = "mailto:";var at = "@";var url = "mysite.com";//User-specific variablesvar strIT_webmaster_url = "webmaster";var strITEmail_webmaster_url = "<a href=" + mailto + strIT_webmaster_url + at + url + subject + ">" + strIT_webmaster_url + at + url + "<\/a>"; XSLT #1: <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> Email: <script language="javascript" type="text/javascript">document.write(strITEmail_webmaster_url);</script> </xsl:template></xsl:stylesheet> This static version works great, but I'm now wanting to pull the JS variable by using a XSLT variable is instead of the static value. This is what that code looks like:XSLT #2: <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" encoding="UTF-8" indent="yes"/><xsl:variable name="email_webmaster">strITEmail_webmaster_url</xsl:variable> <xsl:template match="/"> Email: <script language="javascript" type="text/javascript">document.write(<xsl:value-of select="$email_webmaster" />);</script> </xsl:template></xsl:stylesheet> Although the source code of each looks exactly the same, the result of the 2nd set of code produces an "undefined" value. Is this happening because of the order in which the data is processed, or for some other reason? I'd appreciate any input. Link to comment Share on other sites More sharing options...
kwilliams Posted April 21, 2008 Author Share Posted April 21, 2008 For some reason, it's now working. It must have needed some time to load or something. Thanks anyway. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.