这是我的XML与SOAP标题和正文:XSLT - 删除前缀命名空间特定节点XML
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<RequestResponse xmlns="http://tempuri.org/">
<a:RequestResult xmlns:a="http://schemas.datacontract.org/2004/07/MockupTesting"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:Message>Message text testing.</a:Message>
<a:Response>false</a:Response>
</a:RequestResult>
</RequestResponse>
</s:Body>
</s:Envelope>
我需要从RequestResult
节点只删除前缀。 从这个
<a:RequestResult xmlns:a="http://schemas.datacontract.org/2004/07/MockupTesting"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
要:
<RequestResult xmlns:a="http://schemas.datacontract.org/2004/07/MockupTesting"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
这是XSLT
配置文件我有2版本中使用:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes" />
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<xsl:apply-templates />
</s:Body>
</s:Envelope>
</xsl:template>
<xsl:template match="RequestResult |RequestResult//*">
<xsl:element name="a:{name()}"
namespace="http://schemas.datacontract.org/2004/07/Testing">
<xsl:namespace name="a"
select="'http://schemas.datacontract.org/2004/07/MockupTesting'" />
<xsl:namespace name="i"
select="'http://www.w3.org/2001/XMLSchema-instance'" />
<!-- <xsl:copy-of select="namespace::*" /> -->
<xsl:apply-templates select="node()|@*" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
我要补充或修改,以去除该节点上的前缀?
你不能“删除”命名空间前缀,在绝大多数情况下,你不需要做那样的事情。你能解释一下为什么你认为这是必要的吗? – Tomalak
由于我使用的WSDL,它需要@Tomalak – gtx911
对不起,这不是一个令人满意的解释。我问:“你为什么需要它?”你回答说:“因为我需要它。”我认为你需要给出一个比这更好的理由。 – Tomalak