【发布时间】:2020-05-02 01:44:11
【问题描述】:
我有一个 SOAP 调用返回以下内容:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ns:getTenantResponse xmlns:ns="http://services.mgt.tenant.carbon.wso2.org">
<ns:return xsi:type="ax2696:TenantInfoBean" xmlns:ax2696="http://beans.common.stratos.carbon.wso2.org/xsd" xmlns:ax2698="http://exception.common.stratos.carbon.wso2.org/xsd" xmlns:ax2700="http://api.user.carbon.wso2.org/xsd" xmlns:ax2702="http://beans.mgt.tenant.carbon.wso2.org/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ax2696:active>true</ax2696:active>
<ax2696:admin>admin</ax2696:admin>
<ax2696:adminPassword xsi:nil="true"/>
<ax2696:createdDate>2020-03-31T18:05:30.321-03:00</ax2696:createdDate>
<ax2696:email>erico@mail.com</ax2696:email>
<ax2696:firstname>erico</ax2696:firstname>
<ax2696:lastname>mtx</ax2696:lastname>
<ax2696:originatedService xsi:nil="true"/>
<ax2696:successKey xsi:nil="true"/>
<ax2696:tenantDomain>dom20.com</ax2696:tenantDomain>
<ax2696:tenantId>1</ax2696:tenantId>
<ax2696:usagePlan/>
</ns:return>
</ns:getTenantResponse>
</soapenv:Body>
</soapenv:Envelope>
我需要通过 WSO2 Enterprise Integrator 6.6.0 中的 XSLT 中介处理退货。
一些属性随内容返回:
xsi:nil="true"
我需要我的中介将这些标签替换为我的属性的空值。
我目前的调解员是以下人员:
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.0">
<xsl:output omit-xml-declaration="no" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="*[@xsi:nil = 'true']" />
</xsl:stylesheet>
输出如下:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ns:getTenantResponse xmlns:ns="http://services.mgt.tenant.carbon.wso2.org">
<ns:return xsi:type="ax2696:TenantInfoBean" xmlns:ax2696="http://beans.common.stratos.carbon.wso2.org/xsd" xmlns:ax2698="http://exception.common.stratos.carbon.wso2.org/xsd" xmlns:ax2700="http://api.user.carbon.wso2.org/xsd" xmlns:ax2702="http://beans.mgt.tenant.carbon.wso2.org/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ax2696:active>true</ax2696:active>
<ax2696:admin>admin</ax2696:admin>
<ax2696:adminPassword xsi:nil="true"/>
<ax2696:createdDate>2020-03-31T18:05:30.321-03:00</ax2696:createdDate>
<ax2696:email>erico@skalena.com</ax2696:email>
<ax2696:firstname>erico</ax2696:firstname>
<ax2696:lastname>teixeira</ax2696:lastname>
<ax2696:originatedService xsi:nil="true"/>
<ax2696:successKey xsi:nil="true"/>
<ax2696:tenantDomain>dom20.com</ax2696:tenantDomain>
<ax2696:tenantId>1</ax2696:tenantId>
<ax2696:usagePlan/>
</ns:return>
</ns:getTenantResponse>
</soapenv:Body>
</soapenv:Envelope>
例如:
<ax2696:successKey xsi:nil="true"/>
我需要它变成:
<ax2696:successKey></ax2696:successKey>
我需要对大多数属性执行此操作,而不仅仅是 successKey
感谢
【问题讨论】:
-
你能发布预期的输出吗?
-
你好 Sebastien,我已经用当前输出和我需要的内容更新了内容。谢谢!!
-
我不明白您怎么说您的转换需要 XML 输入并将其转换为某种 JSON?当我对您的输入运行转换时,我得到了预期的 XML 输出。
-
您的问题没有得到解答吗?如果没有,为什么不呢?