<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- attributes, commments, processing instructions, text: copy as is -->
<xsl:template match="@*|comment()|processing-instruction()|text()">
<xsl:copy-of select="."/>
</xsl:template>
<!-- elements: create a new element with the same name, but no namespace -->
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
2 回答
正如其他人所指出的那样,你可能不想这样做 . 如果您希望输出为XHTML,则需要保留XHTML名称空间声明 .
话虽这么说,如果你真的想这样做:
为什么要删除命名空间?它是XHTML规范的一部分,你说你想要XHTML输出 . 那么 - 问题出在哪里?
显然你用
<div>
开始你的输出,否则你将在<html>
元素上有名称空间声明 .