在JavaScript的客户端XSL处理? [英] JavaScript in client-side XSL processing?

查看:91
本文介绍了在JavaScript的客户端XSL处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

时有可能有执行,以协助客户端(基于浏览器),XSL转换XML的嵌入的JavaScript?它是如何做,怎么官呢?

Is it possible to have XML-embedded JavaScript executed to assist in client-side (browser-based) XSL transformations? How is it done and how official is it?

微软的XML DOM对象允许这在服务器侧(即在ASP / ASP.NET)

Microsoft's XML DOM objects allow this on the server-side (i.e. in ASP/ASP.NET).

澄清:我的意思不是HTML DOM脚本执行的之后的文档转换,我也不是说XSL转换的在浏览器中启动的由JavaScript(如什么W3Schools的页所示)。我指的是在转换过程位于XSL中的实际脚本块。

Clarification: I do not mean HTML DOM scripting performed after the document is transformed, nor do I mean XSL transformations initiated by JavaScript in the browser (e.g. what the W3Schools page shows). I am referring to actual script blocks located within the XSL during the transformation.

推荐答案

要嵌入的JavaScript转型的帮助下,您可以使用< XSL:脚本>中,但的这是仅限于微软的XML对象实现。这里有一个例如

To embed JavaScript for the aid of transformation you can use <xsl:script>, but it is limited to Microsoft's XML objects implementation. Here's an example:

scripted.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="scripted.xsl"?>
<data a="v">
    ding dong
</data>

scripted.xsl

<?xml version="1.0" encoding="ISO-8859-1"?>
<html xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:script implements-prefix="local" language="JScript"><![CDATA[

    function Title()
    {
        return "Scripted";
    }

    function Body(text)
    {
        return "/" + text + "/";
    }

]]></xsl:script>
<head>
    <title><xsl:eval>Title()</xsl:eval></title>
</head>
<body>
    <xsl:for-each select="/data"><xsl:eval>Body(nodeTypedValue)</xsl:eval></xsl:for-each>
</body>
</html>

结果在Internet Explorer(或者,如果你只是使用MSXML从COM / .NET)是:

The result in Internet Explorer (or if you just use MSXML from COM/.NET) is:

<html>
<head>
    <title>Scripted</titlte>
</head>
<body>
    /ding dong/
</body>
</html>

有未出现,以支持通常XSL模板构建物和添加根节点导致MSXML进入某种标准模式,其中它将不工作

It doesn't appear to support the usual XSL template constructs and adding the root node causes MSXML to go into some sort of standards mode where it won't work.

我不知道是否有标准的XSL任何同等功能,但我可以梦想。

I'm not sure if there's any equivalent functionality in standard XSL, but I can dream.

这篇关于在JavaScript的客户端XSL处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆