Я не могу изменить имя тегов в ответе SOAP. Я видел много сообщений об этом, но я не нашел подходящего решения.XSLT Soap Message
Мой оригинальный XML является:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<soap:Header>
<MessageID xmlns="http://www.w3.org/2005/08/addressing">uuid:4d6b87d8-fe14-4579-ac34-fe841c184a4b</MessageID>
<RelatesTo RelationshipType="Reply" xmlns="http://www.w3.org/2005/08/addressing">uuid:1f9b0c7e-f36c-4fa3-ac2b-2377b57b6634</RelatesTo>
<Action xmlns="http://www.w3.org/2005/08/addressing">http://xxx</Action>
</soap:Header>
<soap:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<OP1 xmlns="http://xxx/">
<OPR>
<OPO>
<Cod>..</Cod>
<A1>hi my...</A1>
</OPO>
</OPR>
</OP1>
</soap:Body>
</soap:Envelope>
Я хочу изменить A1 для ANAME.
Мой XSL является
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="A1">
<ANAME><xsl:apply-templates /></ANAME>
</xsl:template>
</xsl:stylesheet>
Спасибо!
В вашем XML элемент 'OP1' и все его потомки находятся в пространстве имен' xmlns = "http: // xxx /" '. См. Здесь, как обращаться с ним: http://stackoverflow.com/questions/34758492/xslt-transform-doesnt-work-until-i-remove-root-node/34762628#34762628 - Обратите также внимание, что если вы хотите 'ANAME 'чтобы быть в том же пространстве имен, вы должны поместить его туда. В противном случае вы увидите ' hi my ... ' в выводе. –