I looking for a good example how inject javascript inside of XSLT file and then will be transformed into html. My transformation works very well, but when I following every documentation about adding Script occur error [ERROR]: Cannot find class 'randomString'. [ERROR]: Cannot find external method 'randomString.getZoom' (must be public).
<xsl:stylesheet version="1.0" xmlns:xsl=";
xmlns:exsl=";
extension-element-prefixes="exsl"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="randomString">
<msxsl:script language="JScript" implements-prefix="user">
function getZoom() {
return "#zoom=100";
}
</msxsl:script>
<body>
<xsl:value-of select="user:getZoom()"/>
</body>
Many guys put there some kind of example inside of xmlns:user,but that namespace should be everything,right ? Anyway I need get that string "#zoom=100" into my html body, how ?
I tried get that String into html body.
I looking for a good example how inject javascript inside of XSLT file and then will be transformed into html. My transformation works very well, but when I following every documentation about adding Script occur error [ERROR]: Cannot find class 'randomString'. [ERROR]: Cannot find external method 'randomString.getZoom' (must be public).
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3./1999/XSL/Transform"
xmlns:exsl="http://exslt./common"
extension-element-prefixes="exsl"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="randomString">
<msxsl:script language="JScript" implements-prefix="user">
function getZoom() {
return "#zoom=100";
}
</msxsl:script>
<body>
<xsl:value-of select="user:getZoom()"/>
</body>
Many guys put there some kind of example inside of xmlns:user,but that namespace should be everything,right ? Anyway I need get that string "#zoom=100" into my html body, how ?
I tried get that String into html body.
Share Improve this question asked Jan 29 at 8:00 MichalMichal 11 bronze badge 8 | Show 3 more comments1 Answer
Reset to default 0Summarising what we have learned from the comments thread.
You appear to be using the XSLT processor bundled with the IntelliJ Java IDE, which is probably the version of Xalan that ships with the JDK. This is an XSLT 1.0 processor and it has no support for the Microsoft msxsl:script extension, which is available only in Microsoft XSLT processors.
You appear to be trying to generate an HTML page that contains Javascript functions to implement behaviours such as detecting the user zoom level. Generating HTML that contains Javascript code is no different from generating any other HTML, you don't need Javascript in the XSLT in order to generate Javascript in the HTML.
An alternative design would be to run XSLT within the browser. Take a look at SaxonJS (disclaimer: my company's product). This allows you to write XSLT code that responds directly to user events in the browser, rather than the indirect approach of writing XSLT to generate Javascript to respond to the events.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745305735a4621697.html
msxsl:script
will only work with Microsoft, so if you are using Saxon or Xalan you'll have to adopt their flavor of inline scripting. – Filburt Commented Jan 29 at 9:03xsl:function
as part of the XSLT language instead of needing to delegate work to functions in a proprietary/platform specific scripting language. – Martin Honnen Commented Jan 29 at 9:26