XSLT self-closing tags issue(XSLT 自闭标签问题)
问题描述
我正在使用 xslt 将 xml 文件转换为 html..net xslt 引擎一直为我提供空标签的自闭合标签.
I am using xslt to transform an xml file to html. The .net xslt engine keeps serving me self-closing tags for empty tags.
例子:
<div class="test"></div>
变成
<div class="test" />
前者是合法的html,而后者是非法的html,渲染不好.我的问题是:如何告诉 xslt 引擎 (XslCompiledTransform) 不使用自闭合标签.
The former is valid html, while the latter is illegal html and renders badly. My question is : How do I tell the xslt engine (XslCompiledTransform) to not use self-closing tags.
如果不可能,我如何告诉我的浏览器(在这种情况下为 IE6+)正确解释自闭标签.
If it's not possible, how can I tell my browser (IE6+ in this case) to interpret self-closing tags correctly.
推荐答案
如果您使用 XmlWriter 作为输出流,请改用 HTMLTextWriter.XMLWriter 会将您的 HTML 输出重新格式化为 XML.
If you are using XmlWriter as your ouput stream, use HTMLTextWriter instead. XMLWriter will reformat your HTML output back to XML.
这篇关于XSLT 自闭标签问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:XSLT 自闭标签问题


- 输入按键事件处理程序 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01