【问题标题】:Why can't output '</script>' when using XslCompiledTransform to Transform .xml to .html [duplicate]为什么使用XslCompiledTransform将.xml转换为.html时无法输出'</script>' [重复]
【发布时间】:2015-09-11 02:57:28
【问题描述】:

我想使用XslCompiledTransform 使用 xsl 转换 xml。但是我发现脚本块输出为&lt;script src="..."/&gt; 而不是&lt;script src="..." &gt;&lt;/script&gt;,如何使它正确?

即使我的 xsl 文件如下:

<html>
<head>
    <title>Hello iCore Project</title>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css"/>
<script src="http://code.jquery.com/jquery-1.8.3.min.js" ></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>

</head>

<body>
...

【问题讨论】:

    标签: c# xml xslt


    【解决方案1】:

    在 XML 中,&lt;script ...&gt;&lt;/script&gt;&lt;script ... /&gt; 两种形式均有效且等效。

    要强制结束标签添加&lt;xsl:output method="html"/&gt;到样式表。

    【讨论】:

    • 但是我可以在浏览器(IE,FF,Chrome)中浏览html。如果不添加&lt;/script&gt;可以浏览结果。我不知道为什么
    • @huoxudong125 我怀疑您没有阅读理查德的回答。这两种形式在 xml 和 html 中都是有效且等效的。这就是为什么您可以“浏览结果”。
    • @SeanB.Durkin &lt;xsl:output method="html"/&gt; 没有效果。我试过了;我在&lt;/script&gt;前加;,暂时解决问题。
    猜你喜欢
    • 2013-10-29
    • 1970-01-01
    • 2015-07-29
    • 1970-01-01
    • 2011-03-16
    • 1970-01-01
    • 2020-01-03
    • 2021-11-19
    • 1970-01-01
    相关资源
    最近更新 更多