Я копирую дерево потомков Body. На выходе, как я могу подавить все атрибуты, кроме xmlns = "https://www.google.com/apis/ads/publisher/v201605", который является int дочерним узлом.XSL копирует атрибуты узлов-предков, пока мне нужны только атрибуты из контекстного узла
Вот входной XML
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns1:RequestHeader
soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
soapenv:mustUnderstand="0"
xmlns:ns1="https://www.google.com/apis/ads/publisher/v201605">
<ns1:networkCode>123456</ns1:networkCode>
<ns1:applicationName>DfpApi-Java-2.1.0-dfp_test</ns1:applicationName>
</ns1:RequestHeader>
</soapenv:Header>
<soapenv:Body>
<getAdUnitsByStatement xmlns="https://www.google.com/apis/ads/publisher/v201605">
<filterStatement>
<query>WHERE parentId IS NULL LIMIT 500</query>
</filterStatement>
</getAdUnitsByStatement>
</soapenv:Body>
</soapenv:Envelope>
Вот XSL
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@* | node()">
<xsl:copy-of select=".//*:Body/* " />
</xsl:template>
</xsl:stylesheet>
Вот результат:
<getAdUnitsByStatement xmlns="https://www.google.com/apis/ads/publisher/v201605"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<filterStatement>
<query>WHERE parentId IS NULL LIMIT 500</query>
</filterStatement>
</getAdUnitsByStatement>
Спасибо.
Sandeep
Это помогает знать, что, насколько XSLT является они не являются узлами атрибутов, а узлами пространства имен: надеюсь, что это поможет вам найти нужную информацию в вашем любимом справочнике. –