Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml XSLT 2.0模板匹配-去除不在所需命名空间中的所有属性_Xml_Xslt_Xpath_Xml Namespaces_Xml Attribute - Fatal编程技术网

Xml XSLT 2.0模板匹配-去除不在所需命名空间中的所有属性

Xml XSLT 2.0模板匹配-去除不在所需命名空间中的所有属性,xml,xslt,xpath,xml-namespaces,xml-attribute,Xml,Xslt,Xpath,Xml Namespaces,Xml Attribute,我有一个具有不同名称空间属性的XML,它基本上是一种扩展的XHTML。我想转储所有非xhtml名称空间的属性 示例源XML: <html> <body> <p class="test" xy:foo="true">blah</p> </body> </html> 废话 目前,我有以下XSLT模板: <xsl:template match="@*"> <xsl:choose>

我有一个具有不同名称空间属性的XML,它基本上是一种扩展的XHTML。我想转储所有非xhtml名称空间的属性

示例源XML:

<html>
  <body>
    <p class="test" xy:foo="true">blah</p>
  </body>
</html>

废话

目前,我有以下XSLT模板:

<xsl:template match="@*">
    <xsl:choose>
        <xsl:when test='namespace-uri()="http://www.w3.org/1999/xhtml"'><xsl:copy-of select="."/></xsl:when>
        <xsl:otherwise></xsl:otherwise>
    </xsl:choose>
</xsl:template>

所需的输出XML:

<html>
  <body>
    <p class="test">blah</p>
  </body>
</html>

废话


但它似乎不匹配,因为我得到的输出XML完全没有属性。我感觉
namespace-uri()
没有像预期的那样工作。有什么想法吗?

XHTML元素上的属性(如
one)不在名称空间中,也不在XHTML名称空间中。所以使用

<xsl:template match="@*[namespace-uri() != '']"/>

加上身份转换模板