Hi Rahul,
Merge can be used only for merging XML document types, not for primitive types.
<string>XXX</string> from extractValue represents a primitive type. For your use-case, can you do a merge with Documents and then do a extract value ?
raj. chief masher @ jackbe
Thanks Raj,
It worked, but the o/p is now of the form XXXXXX i.e. the concatination of the two items without any kind of delimiter or spacing. So is there any way I can kind of get a hold on the data and modify it ?
Also I was hoping of publishing it in an html table with some kind of formatting. So is there anyway to spit out an html o/p instead of the xml/rss/grid/maps options present?
I also looked at the mashup studio to see if it has such a functionality but I could not find any.
Can you please give me some suggestions.
Thanks,
Rahul
Hi Rahul,
Can you provide details on service / data you are using ? If you are unable to share the actual services, stubbed Data reflecting your data model would help. If your requirement cannot be met in Wires, we can do it in Mashup Studio / EMML. Here we have full power of XPath / XQuery functionality and it can be used to meet your requirements.
I will await your detailed input data & expected output format.
raj. chief masher @ jackbe
Hi Raj,
Sorry for the delay in replying.
Well I search for a perticular item say 'ipod' on both amazon and ebay and then extract the lowest price using extract document as you suggested. The two documents then are:
<lowest price>
<string>$4.60</string>
</lowest price>
-------------------------------------------
and:
<price>
<string>6.50</string>
<price>
-----------------------------------------------------------------------------------------
Now what i want to do with this data is display it in my final mashlet/widget as
ebay | amazon
$4.60 | $6.50
So I am hoping to display this in an html table format.
The problems I am facing are:
1. Finding a way to display it as an html table.
2. Merging the two xml's into a single xml with both the lowest price's. (Assuming that helps in displaying it in the table).
3. Adding a '$' sign in the second xml.
Hope you have understood my objective. Can you please suggest any way to do this?
Thanks,
Rahul
Hi Rahul,
I tried the Merge using the following data:
<?xml version="1.0" encoding="utf-8"?>
<item>
<lowest-price>
<string>
4.60
</string>
</lowest-price>
</item>
and
<?xml version="1.0" encoding="utf-8"?>
<item>
<price>
<string>
5.60
</string>
</price>
</item>
Merge worked fine and I got the result as :
item :
lowest-price : string: 4.60
price: string: 5.60
Not sure what is exactly wrong with this.
I realized that you eventually want to display the results in a HTML file. Here is an example of invoking this Mashup and rendering the output in HTML. The assumption is that you have created a Mashup by name "testMerge" (change it to whatever you want) using Wires that returns this merged data.
<code>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Test</title>
<script type="text/javascript" src="http://localhost:8080/static/common/js/prototype/prototype-1.6.0.js"></script>
<script type="text/javascript" src="http://localhost:8080/static/common/js/presto-util.js"></script>
<script type="text/javascript" src="http://localhost:8080/static/common/js/presto-connect.js"></script>
</head>
<body>
<div id="merge-result" sytle="width: 300px; height: 300px;">
<table>
<tr>
<th>Ebay Price</th>
<th>Amazon Price</th>
</tr>
<tr>
<td>$<span id="ebayPrice"></span></td>
<td>$<span id="amazonPrice"></span></td>
</tr>
</table>
</div>
</body>
<script>
var connection = new Presto.Connection({
prestoUrl: 'http://127.0.0.1:8080/presto',
username: 'admin',
password: 'adminadmin'
});
connection.request({
sid: 'testMerge', // name of the Service that returns the merged data
oid: 'runMashup' // all services created via Wires will have "runMashup" as the name of the operation
}, {
onSuccess: function(response){
console.log('got response from server');
console.log(response);
var data = response.response; // response.response gives the data
$('ebayPrice').innerHTML = data.item['lowest-price'].string;
$('amazonPrice').innerHTML = data.item.price.string;
},
onFailure: function(e){
console.log(e);
},
scope: this
});
</script>
</html>
</code>
Hi,
Thank you for the reply!
The problem I was facing with the merge was that it did not have the common 'item' parent node as is there in your example. So the output of my merge would end up coming as:
<lowest-price>
<string>
4.605.60
</string>
</lowest-price>
That is both the prices without any delimiter. So is there anyway to introduce a parent element while using extract document? or is there anyway to edit the merge result to insert a space or a comma?
Thanks,
Rahul
Hi Rahul,
Looks like you are hitting some current wires limitation.
For increased flexibility, you can fallback to Mashup Studio where you will have full power of EMML to customize your needs.
For example, you can use constructor to build customized documents to meet your needs.
<variables>
<variable name="price1" type="document">
<lowestprice>
<string>$4.60</string>
</lowestprice>
</variable>
<variable name="price2" type="document">
<price>
<string>6.50</string>
</price>
</variable>
</variables>
<constructor outputvariable="result">
<prices>
<price>{$price1//lowestprice/string()}</price>
<price>{$price2//price/string()}</price>
</prices>
</constructor>
raj. chief masher @ jackbe



Hi,
I am trying to make a very basic mashup for comparative shopping.
What I am doing is, searching for the item on amazon and ebay and then I use the 'extract value' on each of them to get the lowest value at which the item is available.
The o/p of the extract value for both of them are of the form <string>XXX</string>
Now, when I try to merge these, the merge tool just gives <string/> as the o/p. It omits the data between the tags.
What I am expecting is something like:
<string>XXX</string>
<string>XXX</string>
Can someone help me out?
Thanks,
Rahul