Mule:使用来自数据库的其他信息来丰富XML [英] Mule: Enriching an XML with additional information from DB
问题描述
我在Mule流程中加入了XML.我还想添加/修改它的其他值.例如,下面是结构:
I have an XML coming into my Mule process. I further want to add/modify it further values. For example here is the structure:
<Order xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:/XML/PO/Outbound/XML/PO.xsd">
<TransactionId>376721</TransactionId>
<TransactionDateTime>2014-01-30T00:00:00</TransactionDateTime>
<Parties>
<Party>
<PartyType>Sold</PartyType>
<PartyCode>106246</PartyCode>
<FirstName>John</FirstName>
<CompanyName>100</CompanyName>
<Address1>1916 Quino Street</Address1>
<CityName>San Francisco</CityName>
<StateOrProvinceCode>CA</StateOrProvinceCode>
<PostalCode>94805</PostalCode>
<CountryCode>USA</CountryCode>
<PhoneNumber>5102333333</PhoneNumber>
</Party>
<Party>
<PartyType>DC</PartyType>
<Address1/>
<Address2/>
<Address3/>
<CityName/>
<StateOrProvinceCode/>
<PostalCode/>
<PhoneNumber/>
</Party>
<Party>... </Party>
</Parties>
...
</Order>
现在,我在数据库中具有Address1/Address2/Address3值.我需要提取它&使用该数据进一步丰富XML.我可以使用JDBC数据库适配器来获取这些值.通过&来使用检索到的值修改XML的最佳方法是什么?然后进一步处理XML?
Now I have the Address1/Address2/Address3 values in a database. I need to extract it & further enrich the XML with that data. I can use a JDBC database adapter to get at the values. What is the best way to modify the XML with the retrieved values though & then further process the XML?
推荐答案
从Mule中的 XML 中提取值的最佳方法是使用 XPATH . 这是参考:- https://developer.mulesoft.com/docs/display/当前/XPath
The best way to extract the value from XML in Mule is using XPATH. Here is the reference :- https://developer.mulesoft.com/docs/display/current/XPath
如果要使用检索的值修改XML,最好的方法是在Mule流中使用 XSLT . ://developer.mulesoft.com/docs/display/current/XSLT+Transformer"rel =" nofollow noreferrer> https://developer.mulesoft.com/docs/display/current/XSLT+Transformer
And if you want to modify the XML with retrieved values, the best way is to use XSLT in Mule flow.. reference :- https://developer.mulesoft.com/docs/display/current/XSLT+Transformer
You can also see the reference here for doing it :- how to add a node in a xml payload in mule
这篇关于Mule:使用来自数据库的其他信息来丰富XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!