首页 > 解决方案 > 如何删除与属性关联的 Soap 命名空间

问题描述

我必须删除与 ConfigR(属性)关联的肥皂名称空间。

在 XSLT 内部,我使用的是 XSL Copy,因此排除前缀不起作用。

我在下面尝试过,但没有工作。请任何人建议。

     <?xml version="1.0" encoding="UTF-8"?>
      <xsl:stylesheet version="1.0" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
     <xsl:output indent="yes"/>
     <xsl:template match="@* | node()">
    <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
      </xsl:copy>
     </xsl:template>
      <xsl:template match="soapenv:*">
   <xsl:apply-templates select="@* | node()"/>
       </xsl:template>
       </xsl:stylesheet>

输入 -

              <soapenv:Envelope 
           xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
         <soapenv:Body>
      <ConfigR>
        Inside I have some more input.
      </ConfigR>
        </soapenv:Body>
         </soapenv:Envelope>   




     Now in Output I am getting:
         <ConfigR xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 

标签: xslt-2.0xslt-3.0

解决方案


您可以替换现有模板:

<xsl:template match="@* | node()">
    <xsl:copy>
        <xsl:apply-templates select="@* | node()" />
    </xsl:copy>
</xsl:template>

有以下内容:

<xsl:template match="*">
    <xsl:element name="{local-name(.)}">
        <xsl:apply-templates select="@* | node()" />
    </xsl:element>
</xsl:template>
<xsl:template match="@*">
    <xsl:attribute name="{local-name(.)}">
        <xsl:value-of select="." />
    </xsl:attribute>
</xsl:template>

你可以在这里找到


推荐阅读