Xslt 删除元素的命名空间和命名空间前缀

Xslt 删除元素的命名空间和命名空间前缀,xslt,Xslt,亲爱的专家们,我有SOAP Env的输入请求,这些请求只需要使用XSLT捕获 同时,需要删除元素上的名称空间以及每个元素的名称空间前缀。 输入请求 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"

亲爱的专家们,我有SOAP Env的输入请求,这些请求只需要使用XSLT捕获 同时,需要删除元素上的名称空间以及每个元素的名称空间前缀。

输入请求

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
xmlns:v1="http://xmldefs. ag.com/Applications/eer/V1">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<v1:ProcessDistr xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <v1:Group xmlns:ns2="http://xmldefs.ag.com/DD/Commons">
    <v1:GroupID>437848</v1: GroupID>
    <v1:Status>true</v1:Status>
    <v1:Parent>45434554</v1:Parent>
  </v1:Group>
</v1:ProcessDistr>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<ProcessDistr >
  <Group >
    <GroupID>437848</GroupID>
    <Status>true</Status>
    <Parent>45434554</Parent>
  </Group>
</ProcessDistr>

437848
真的
45434554
收到的输出

    <?xml version="1.0" encoding="UTF-8"?>
    <v1:ProcessDistr xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsu=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://xmldefs. ag.com/Applications/eer/V1">
      <v1:Group xmlns:ns2="http://xmldefs.ag.com/DD/Commons">
        <v1:GroupID>437848</v1: GroupID>
        <v1:Status>true</v1:Status>
        <v1:Parent>45434554</v1:Parent>
      </v1:Group>
    </v1:ProcessDistr>

437848
真的
45434554
XSLT代码

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"  xmlns:v1="http://xmldefs. ag.com/Applications/eer/V1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsltc="http://xml.apache.org/xalan/xsltc" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sap="http://www.sap.com/sapxsl" xmlns:prof="http://ixult.net/ProfileExchange" exclude-result-prefixes ="v1" xmlns:wsu=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" >
       <!-- Output -->
       <xsl:output encoding="UTF-8" indent="yes" method="xml" omit-xml-declaration="yes"/>


       <xsl:template match="/">
          <!-- filter ProcessDistr-->

             <xsl:copy-of select="//v1:ProcessDistr"/>

       </xsl:template>
    </xsl:stylesheet>

我期待这一结果

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
xmlns:v1="http://xmldefs. ag.com/Applications/eer/V1">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<v1:ProcessDistr xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <v1:Group xmlns:ns2="http://xmldefs.ag.com/DD/Commons">
    <v1:GroupID>437848</v1: GroupID>
    <v1:Status>true</v1:Status>
    <v1:Parent>45434554</v1:Parent>
  </v1:Group>
</v1:ProcessDistr>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<ProcessDistr >
  <Group >
    <GroupID>437848</GroupID>
    <Status>true</Status>
    <Parent>45434554</Parent>
  </Group>
</ProcessDistr>

437848
真的
45434554
你能告诉我你对此的看法吗

多谢各位

致以最良好的祝愿, Sateesh N


试试这个

您想要的结果可以通过以下方式实现:

XSLT1.0

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:v1="http://xmldefs.ag.com/Applications/eer/V1">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

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

</xsl:stylesheet>



Demo(删除输入中多余的空格后):

为什么不简单地
?你好,Michael,你能详细介绍一下你的逻辑简单方法吗?