XSLT does not output single <br> tag

This is somewhat related to XSLT wont allow me to use self-closing img and br tags but I don't think it's a duplicate.

I want to transform XML to HTML. In the source XML, there are self-closing <lb/> elements. I want to transform these into valid HTML <br> void elements.

To get valid HTML, I set the output method to HTML:

<xsl:output method="html" encoding="UTF-8" indent="no"/>

The XSLT code looks like this:

<xsl:template match="//lb">
    <br/>
</xsl:template>

But as output, I get this

<br></br>

which is interpreted by an HTML5 parser as

<br><br>

How to get one valid HTML void element?

链接地址: http://www.djcxy.com/p/76880.html

上一篇: 使用Python从HTML文件中提取文本

下一篇: XSLT不输出单个<br>标记