如何删除xslt中的名称空间

如何删除xslt中的名称空间,xslt,xhtml,Xslt,Xhtml,使用xslt,我试图获得xhtml o/p。我使用了xmlns=”http://www.w3.org/1999/xhtml“在 要获得xhtml o/p,一切都很好,但在第一个div中,我得到了相同的名称空间。i、 e <div xmlns="http://www.w3.org/1999/xhtml"> 现在,如何删除xmlns=”http://www.w3.org/1999/xhtml“为什么要删除命名空间?它是XHTML规范的一部分,您可以说您想要XHTML输出。那

使用xslt,我试图获得xhtml o/p。我使用了xmlns=”http://www.w3.org/1999/xhtml“在


要获得xhtml o/p,一切都很好,但在第一个div中,我得到了相同的名称空间。i、 e

 <div  xmlns="http://www.w3.org/1999/xhtml">


现在,如何删除xmlns=”http://www.w3.org/1999/xhtml“

为什么要删除命名空间?它是XHTML规范的一部分,您可以说您想要XHTML输出。那么,问题出在哪里


显然,您是以
开始输出的,否则您将在
元素上声明名称空间。

为什么要删除名称空间?它是XHTML规范的一部分,您可以说您想要XHTML输出。那么,问题出在哪里


显然,您是以
开始输出的,否则您将在
元素上声明名称空间。

正如其他人所指出的,您可能不想这样做。如果希望输出为XHTML,则需要保留XHTML名称空间声明

也就是说,如果你真的想这么做:

<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>

正如其他人所指出的,您可能不想这样做。如果希望输出为XHTML,则需要保留XHTML名称空间声明

也就是说,如果你真的想这么做:

<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>


没错,它会出现,但有没有办法删除名称空间。再说一遍:为什么?它属于XHTML,必须存在。没错,它会出现,但有没有办法删除名称空间。再说一遍:为什么?它属于XHTML,必须在那里。您能发布您的XSLT样式表和输出标记吗?您能发布您的XSLT样式表和输出标记吗?