XSLT自动关闭标签问题 [英] XSLT self-closing tags issue
问题描述
我正在使用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自动关闭标签问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!