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 删除一些带有XLS的名称空间前缀_Xml_Xslt_Namespaces - Fatal编程技术网

Xml 删除一些带有XLS的名称空间前缀

Xml 删除一些带有XLS的名称空间前缀,xml,xslt,namespaces,Xml,Xslt,Namespaces,这是我的XML <soapenv:Envelope xmlns:ns="urn:sap-com:document:sap:rfc:functions" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header/> <soapenv:Body> <ns:BAPI_PRODORD_GET_LIST> <ns:ORD

这是我的XML

<soapenv:Envelope xmlns:ns="urn:sap-com:document:sap:rfc:functions" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <ns:BAPI_PRODORD_GET_LIST>
         <ns:ORDER_NUMBER_RANGE>
            <ns:Item>
               <ns:SIGN>I</ns:SIGN>
               <ns:OPTION>EQ</ns:OPTION>
               <ns:LOW>150000033760</ns:LOW>
               <ns:HIGH>150000033765</ns:HIGH>
            </ns:Item>
         </ns:ORDER_NUMBER_RANGE>
         <ns:PLANPLANT_RANGE>
            <ns:Item>
               <ns:SIGN>I</ns:SIGN>
               <ns:OPTION>EQ</ns:OPTION>
               <ns:LOW>TM04</ns:LOW>
            </ns:Item>
         </ns:PLANPLANT_RANGE>
      </ns:BAPI_PRODORD_GET_LIST>
   </soapenv:Body>
</soapenv:Envelope>
其余部分必须保持不变。

此样式表

<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ns="urn:sap-com:document:sap:rfc:functions">
    <xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="ns:*//@*">
        <xsl:attribute name="{local-name()}">
            <xsl:value-of select="."/>
        </xsl:attribute>
    </xsl:template>
    <xsl:template match="ns:*//*">
        <xsl:element name="{local-name()}">
            <xsl:apply-templates select="node()|@*"/>
        </xsl:element>
    </xsl:template>
</xsl:stylesheet>

输出:

<soapenv:Envelope xmlns:ns="urn:sap-com:document:sap:rfc:functions"
 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <ns:BAPI_PRODORD_GET_LIST>
         <ORDER_NUMBER_RANGE>
            <Item>
               <SIGN>I</SIGN>
               <OPTION>EQ</OPTION>
               <LOW>150000033760</LOW>
               <HIGH>150000033765</HIGH>
            </Item>
         </ORDER_NUMBER_RANGE>
         <PLANPLANT_RANGE>
            <Item>
               <SIGN>I</SIGN>
               <OPTION>EQ</OPTION>
               <LOW>TM04</LOW>
            </Item>
         </PLANPLANT_RANGE>
      </ns:BAPI_PRODORD_GET_LIST>
   </soapenv:Body>
</soapenv:Envelope>

我
情商
150000033760
150000033765
我
情商
TM04
这将使用“覆盖标识规则”模式

<Envelope>
   <Header/>
   <Body>
      <BAPI_PRODORD_GET_LIST>
         <ORDER_NUMBER_RANGE>
            <Item>
               <SIGN>I</SIGN>
               <OPTION>EQ</OPTION>
               <LOW>150000033760</LOW>
               <HIGH>150000033765</HIGH>
            </Item>
         </ORDER_NUMBER_RANGE>
         <PLANPLANT_RANGE>
            <Item>
               <SIGN>I</SIGN>
               <OPTION>EQ</OPTION>
               <LOW>TM04</LOW>
            </Item>
         </PLANPLANT_RANGE>
      </BAPI_PRODORD_GET_LIST>
   </Body>
</Envelope>
<ns:BAPI_PRODORD_GET_LIST>
<ns:ORDER_NUMBER_RANGE>
<ns:Item>
<ns:SIGN>I</ns:SIGN>
...
</ns:BAPI_PRODORD_GET_LIST>
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:ns="urn:sap-com:document:sap:rfc:functions">
    <xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="ns:*//@*">
        <xsl:attribute name="{local-name()}">
            <xsl:value-of select="."/>
        </xsl:attribute>
    </xsl:template>
    <xsl:template match="ns:*//*">
        <xsl:element name="{local-name()}">
            <xsl:apply-templates select="node()|@*"/>
        </xsl:element>
    </xsl:template>
</xsl:stylesheet>
<soapenv:Envelope xmlns:ns="urn:sap-com:document:sap:rfc:functions"
 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <ns:BAPI_PRODORD_GET_LIST>
         <ORDER_NUMBER_RANGE>
            <Item>
               <SIGN>I</SIGN>
               <OPTION>EQ</OPTION>
               <LOW>150000033760</LOW>
               <HIGH>150000033765</HIGH>
            </Item>
         </ORDER_NUMBER_RANGE>
         <PLANPLANT_RANGE>
            <Item>
               <SIGN>I</SIGN>
               <OPTION>EQ</OPTION>
               <LOW>TM04</LOW>
            </Item>
         </PLANPLANT_RANGE>
      </ns:BAPI_PRODORD_GET_LIST>
   </soapenv:Body>
</soapenv:Envelope>