我希望将肥皂消息转换成肥皂消息,使用mule中的xslt
我没有将肥皂消息1中的元素添加到肥皂消息2
1。我有肥皂
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<ns:topic xmlns:ns="http://wso2.org/ns/2009/09/eventing/notify">polling_Topic</ns:topic>
</soapenv:Header>
<soapenv:Body>
<data-services-event>
<service-name>pollingService</service-name>
<query-id>pollingQuery</query-id>
<time>Wed May 24 10:01:18 ICT 2017</time>
<content>
<Students xmlns="http://ws.wso2.org/dataservice/samples/eventing_sample">
<student>
<count>25</count>
<id>25</id>
<Name>Tran Anh</Name>
<Contact>Dong Thap</Contact>
<regdatetime>2017-05-23T14:41:35.000+07:00</regdatetime>
</student>
</Students>
</content>
</data-services-event>
</soapenv:Body>
</soapenv:Envelope>
</soap:Body>
</soap:Envelope>
这是transform.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dat="http://dataservice.ws.wso2.org">
<soapenv:Header/>
<soapenv:Body>
<dat:insertPerson>
<!--Optional:--><dat:name><xsl:value-of select="soapenv:Envelope/soapenv:Body/data-services-event/content/Students/student/Name" /></dat:name>
<!--Optional:--><dat:contact><xsl:value-of select="data-services-event/content/Students/student/Contact/text()" /></dat:contact>
</dat:insertPerson>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
</xsl:stylesheet>
我收到结果:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:dat="http://dataservice.ws.wso2.org"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<dat:insertPerson>
<dat:name/>
<dat:contact/>
</dat:insertPerson>
</soapenv:Body>
</soapenv:Envelope>
我没有得到元素:姓名和联系方式
怎么做
答案 0 :(得分:0)
有两个原因导致您无法获得预期值。一个是你的路径缺少一些位置步骤。另一个是Students
元素及其后代位于命名空间中,您需要使用绑定到同一命名空间的前缀来选择它们。
这是你的样式表,有一些修改:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:dat="http://dataservice.ws.wso2.org"
xmlns:stu="http://ws.wso2.org/dataservice/samples/eventing_sample"
exclude-result-prefixes="stu">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<soapenv:Envelope >
<soapenv:Header/>
<soapenv:Body>
<dat:insertPerson>
<dat:name>
<xsl:value-of select="soapenv:Envelope/soapenv:Body/soapenv:Envelope/soapenv:Body/data-services-event/content/stu:Students/stu:student/stu:Name" />
</dat:name>
<dat:contact>
<xsl:value-of select="soapenv:Envelope/soapenv:Body/soapenv:Envelope/soapenv:Body/data-services-event/content/stu:Students/stu:student/stu:Contact" />
</dat:contact>
</dat:insertPerson>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
</xsl:stylesheet>