Xml 删除一些带有XLS的名称空间前缀
这是我的XMLXml 删除一些带有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
<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>