10 javascript xslt
我正在使用xslt将xml转换为aspx文件.在xslt中,我有一个脚本标记包含一个jquery.js文件.要使其与IE一起使用,脚本标记必须具有明确的结束标记.出于某种原因,这不适用于下面的xslt.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
xmlns:asp="remove">
<xsl:output method="html"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TEST</title>
<script type="text/javascript" src="jquery-1.2.6.js"></script>
Run Code Online (Sandbox Code Playgroud)
但是,如果我更改脚本标记,如下所示,它的工作原理.
<script type="text/javascript" src="jquery-1.2.6.js">
// <![CDATA[ // ]]>
</script>
Run Code Online (Sandbox Code Playgroud)
我认为<xsl:output method="html" />
可以做到这一点,但它似乎没有用?
/乔纳斯
如果您自己创建XmlWriter,则需要将transform的OutputSettings传递给XmlWriter,例如:
XmlDocument doc = new XmlDocument();
doc.LoadXml("<book><author>Trudi Canavan</author><title>Voice of the Gods</title></book>");
XslCompiledTransform transform = new XslCompiledTransform();
transform.Load("XSLTFile1.xslt");
StringBuilder output = new StringBuilder();
// Here we pass the output setting to the writer, otherwise the transform
// may be set to Html, but the XmlWriter will be outputting Xml
XmlWriter writer = XmlWriter.Create(output, transform.OutputSettings);
transform.Transform(doc, writer);
Console.WriteLine(output.ToString());
Console.ReadKey();
Run Code Online (Sandbox Code Playgroud)
这当然是针对 MS 的 XSLT 引擎吗?多么奇怪。我不能说我在 .NET 1.1 或 2.0 中遇到过这种情况,并且我有许多转换在做完全相同的事情,所以我建议您使用简单的解决方法。
归档时间: |
|
查看次数: |
10292 次 |
最近记录: |