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 自闭标签问题
基础教程推荐
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
