0

I try to call javascript function xslt ? why it is not called?

http://xsltransform.net/gWEamLX

I tried like this

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:jscript="http://www.url.com"
exclude-result-prefixes="msxsl jscript">
    <xsl:output method="html" doctype-public="XSLT-compat" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />

    <xsl:template match="/">
      <hmtl>
        <head>
          <title>New Version!</title>
        </head>
          <xsl:variable name="sVar" select="'ss'"/>

<xsl:value-of select="jscript:getRegion(string($sVar))"/>
        <msxsl:script language="JScript" implements-prefix="jscript">
function getRegion(sVar){
alert(sVar)
}
</msxsl:script>
      </hmtl>
    </xsl:template>


</xsl:transform>

I take reference from here Calling a user defined function written in javascript using xsl why alert is not showing

6
  • Why would a stylesheet alert anything? Are you opening this in a browser? Commented Feb 22, 2017 at 17:07
  • Not sure about jscript, though you can call javascript function within xhtml document. Commented Feb 22, 2017 at 17:10
  • sorry for late reply ..yes I need to open in browser Commented Feb 22, 2017 at 17:23
  • @guest271314 how we can call Commented Feb 22, 2017 at 17:24
  • 2
    So which XSLT processor do you use where you expect msxsl:script to be supported? And even when supported, why do you expect the alert function, which is not a function implemented by an Javascript engine, but rather by browsers, to work? If you have an XSLT processor like MSXML 3 or 6 supporting msxsl:script then you only have support for core objects/functions/data types implemented by the JScript engine msdn.microsoft.com/en-us/library/yek4tbz0(v=vs.85).aspx Commented Feb 22, 2017 at 18:07

1 Answer 1

0

Calling mechanisms from XSLT to external languages such as Java or Javascript depend entirely on which XSLT processor you are using. You haven't said which XSLT processor you are using, but it is presumably one that either (a) does not support calling to Javascript, or (b) doesn't support calling to Javascript using this particular Microsoft-defined syntax.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.