使用浏览器测试 xslt 代码 [英] Testing xslt code using your browser

查看:24
本文介绍了使用浏览器测试 xslt 代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用我的浏览器,我想测试我的 xslt 代码是否有效.

Using my browser, I want to test if my xslt code is working.

目前我正在将我的 xml 和 xslt 代码复制粘贴到 w3school 的示例页面并在那里进行测试.

Currently I am copy pasting my xml and xslt code into w3school's example page and test it there.

然而,这是一个真正的痛苦,因为在那里插入选项卡不起作用,语法突出显示不活动并且输出窗口太小.通常在那里测试您的代码不方便.

However, this is a real pain, since inserting tabs don't work there, syntax highlighting isn't active and the output window is too small. It is inconvenient to test your code there in general.

所以:

  • 我必须设置什么来测试我的 xslt 代码?
  • 我是否必须将 xslt 文件的名称更改为 xhtml 或 html?
  • 您通常如何测试 xslt 代码?

例如,我想在浏览器中调用链接 file://code.xslt 并查看结果.

I want to call the link file://code.xslt in my browser and see the result, for example.

我使用的是 Ubuntu、Linux.

I am on Ubuntu, Linux.

为了规避 chrome 的同源策略,我不得不使用 google-chrome --allow-file-access-from-files 重新启动 chrome.

To circumvent chrome's same origin policy, I had to restart chrome with google-chrome --allow-file-access-from-files.

这里这里是更多信息.

推荐答案

在浏览器中测试 XSLT 的一种非常简单的方法是将以下标题添加到您的 XML 源文档中:

A super-simple way to test your XSLT in a browser is to add the following header to your XML source document:

<?xml-stylesheet type="text/xsl" href="mystylesheet.xsl"?>

然后在浏览器中加载它(XML 源代码).

then load it (the XML source) in the browser.

另一种选择是使用带有一些 javascript 的独立 HTML 文档来加载您的 XML 和 XSLT 文档并启动转换.

Another option is to use a stand-alone HTML document with some javascript to load your XML and XSLT documents and initiate the transform.

这些都不能真正取代专用应用程序.另请注意,您已使用 XSLT 2.0 对此进行了标记,但我不知道有任何支持它的浏览器.

None of these can really replace a dedicated application. Note also that you have tagged this with XSLT 2.0, but I don't know of any browser that supports it.

这篇关于使用浏览器测试 xslt 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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