datasource-io-source.mustache revision df3b7a1f325a79c0c17a7080446869b612514026
36983956d7c3d9e294903eeda29548f67ac17daeBob Halley<style scoped>
40d01ce8f3a1889f5799d9b22b26d5398fa75a1bBob Halley/* custom styles for this example */
b90dd6c0a9df584619d3c47be7c9417f55d5ccf6Bob Halley#demo .output {margin-bottom:1em; padding:10px; border:1px solid #D9D9D9;}
16803617e47c83272013e45ba8eb83a3b11983edAndreas Gustafsson<form id="demo">
16803617e47c83272013e45ba8eb83a3b11983edAndreas Gustafsson "ResultSet": {
fd9b6f253eac9dae2e1ad19d49aaa922d5d4f274Mark Andrews "totalResultsAvailable":391000000,
16803617e47c83272013e45ba8eb83a3b11983edAndreas Gustafsson "totalResultsReturned":10,
16803617e47c83272013e45ba8eb83a3b11983edAndreas Gustafsson "firstResultPosition":1,
16803617e47c83272013e45ba8eb83a3b11983edAndreas Gustafsson {"Title":"Madonna","Summary":"Official site of pop diva
16803617e47c83272013e45ba8eb83a3b11983edAndreas Gustafsson Madonna, with news, music, media, and fan club.",
16803617e47c83272013e45ba8eb83a3b11983edAndreas Gustafsson "Url":"http:\/\/www.madonna.com\/", ...,
16803617e47c83272013e45ba8eb83a3b11983edAndreas Gustafsson "Size":"145030"}},
16803617e47c83272013e45ba8eb83a3b11983edAndreas Gustafsson {"Title":"Madonna - MySpace","Summary":"Madonna MySpace
16803617e47c83272013e45ba8eb83a3b11983edAndreas Gustafsson page features news, blog, music downloads, desktops,
16803617e47c83272013e45ba8eb83a3b11983edAndreas Gustafsson wallpapers, and more.",
16803617e47c83272013e45ba8eb83a3b11983edAndreas Gustafsson "Url":"http:\/\/www.myspace.com\/madonna",
16803617e47c83272013e45ba8eb83a3b11983edAndreas Gustafsson ..., "Size":"110365"}},
16803617e47c83272013e45ba8eb83a3b11983edAndreas Gustafsson {"Title":"YouTube - madonna's Channel",
16803617e47c83272013e45ba8eb83a3b11983edAndreas Gustafsson "Summary":"The Official Madonna YouTube Channel.
b90dd6c0a9df584619d3c47be7c9417f55d5ccf6Bob Halley Want to Subscribe? ... http:\/\/www.youtube.com\/Madonna.
b90dd6c0a9df584619d3c47be7c9417f55d5ccf6Bob Halley Sharing Options There are 3 ways to share this channel.",
b90dd6c0a9df584619d3c47be7c9417f55d5ccf6Bob Halley "Url":"http:\/\/youtube.com\/madonna", ...,
b90dd6c0a9df584619d3c47be7c9417f55d5ccf6Bob Halley "Size":"49955"}},
16803617e47c83272013e45ba8eb83a3b11983edAndreas Gustafsson <h6>Schema</h6>
70680fa51b0147c726b939b72b2420249429756aBob Halley resultListLocator: "ResultSet.Result",
276a77c22af98c78403883b16a82646a0d5b29abPaul Vixie resultFields: ["Title"]
553ead32ff5b00284e574dcabc39115d4d74ec66Evan Hunt <h6>Normalized data</h6>
553ead32ff5b00284e574dcabc39115d4d74ec66Evan Hunt <input type="button" id="demo_json" value="Retrieve data">
553ead32ff5b00284e574dcabc39115d4d74ec66Evan Hunt <div id="demo_output_json" class="output"></div>
553ead32ff5b00284e574dcabc39115d4d74ec66Evan Hunt <h4>XML</h4>
af104911b781444e0b2d3da9df553897e511303aEvan Hunt <h6>Data</h6>
553ead32ff5b00284e574dcabc39115d4d74ec66Evan Hunt<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
553ead32ff5b00284e574dcabc39115d4d74ec66Evan Hunt yahoo:count="10" ...>
553ead32ff5b00284e574dcabc39115d4d74ec66Evan Hunt <diagnostics>
b272d38cc5d24f64c0647a9afb340c21c4b9aaf7Evan Hunt </diagnostics>
b272d38cc5d24f64c0647a9afb340c21c4b9aaf7Evan Hunt <results>
b272d38cc5d24f64c0647a9afb340c21c4b9aaf7Evan Hunt <result xmlns="http://www.inktomi.com/">
523598fafa87b0b1abb5a3a2913522e5e0716f6dEvan Hunt <dispurl>
523598fafa87b0b1abb5a3a2913522e5e0716f6dEvan Hunt <![CDATA[www.<b>madonna.com</b>]]>
553ead32ff5b00284e574dcabc39115d4d74ec66Evan Hunt </dispurl>
d699672160ba01589227ac046a28e20d55336facEvan Hunt <size>144947</size>
d699672160ba01589227ac046a28e20d55336facEvan Hunt <title>
d699672160ba01589227ac046a28e20d55336facEvan Hunt <![CDATA[<b>madonna</b>.com home]]>
d699672160ba01589227ac046a28e20d55336facEvan Hunt </title>
0e4fda8862cc0d04a54faba5c54eab5e7517ec58Evan Hunt </result>
d699672160ba01589227ac046a28e20d55336facEvan Hunt <result xmlns="http://www.inktomi.com/">
a88f8c2dd19a6483ccaacaaf57b2ceac44737483Evan Hunt <dispurl>
a88f8c2dd19a6483ccaacaaf57b2ceac44737483Evan Hunt <![CDATA[<b>en.wikipedia.org</b>/wiki/<wbr>
40d0f115a64595aa83cfe0b760587d3d1efa0385Tatuya JINMEI 神明達哉 <b>Madonna</b>_(entertainer)]]>
28479307225582ad0b2e11441d85fcf5169551d0Mark Andrews </dispurl>
28479307225582ad0b2e11441d85fcf5169551d0Mark Andrews <size>450316</size>
28479307225582ad0b2e11441d85fcf5169551d0Mark Andrews <title>
28479307225582ad0b2e11441d85fcf5169551d0Mark Andrews <![CDATA[<b>Madonna</b> (Entertainer) - Wikipedia]]>
28479307225582ad0b2e11441d85fcf5169551d0Mark Andrews </title>
6cdaeb94d4d12b72b919f3c7099f7c47c172b59bEvan Hunt <url>http://en.wikipedia.org/wiki/Madonna_(entertainer)</url>
6cdaeb94d4d12b72b919f3c7099f7c47c172b59bEvan Hunt </result>
6cdaeb94d4d12b72b919f3c7099f7c47c172b59bEvan Hunt <result xmlns="http://www.inktomi.com/">
6cdaeb94d4d12b72b919f3c7099f7c47c172b59bEvan Hunt <dispurl>
6cdaeb94d4d12b72b919f3c7099f7c47c172b59bEvan Hunt <![CDATA[www.<b>myspace.com</b>/<b>madonna</b>]]>
6cdaeb94d4d12b72b919f3c7099f7c47c172b59bEvan Hunt </dispurl>
6cdaeb94d4d12b72b919f3c7099f7c47c172b59bEvan Hunt <size>110851</size>
6cdaeb94d4d12b72b919f3c7099f7c47c172b59bEvan Hunt <title>
bcfb2cead57dcc6b678abbf0161c1cab989d6de1Mark Andrews <![CDATA[<b>Madonna</b> - MySpace]]>
bcfb2cead57dcc6b678abbf0161c1cab989d6de1Mark Andrews </title>
6cdaeb94d4d12b72b919f3c7099f7c47c172b59bEvan Hunt <url>http://www.myspace.com/madonna</url>
6cdaeb94d4d12b72b919f3c7099f7c47c172b59bEvan Hunt </result>
f6f1672b4e460571c418e43ae3bd0fae97e4c149Mark Andrews </results>
f6f1672b4e460571c418e43ae3bd0fae97e4c149Mark Andrews</query>
5a8bebe00df211d4fdac3edc36cf35e1d5af42e0Mark Andrews <h6>Schema</h6>
5a8bebe00df211d4fdac3edc36cf35e1d5af42e0Mark Andrews resultListLocator: "result",
5a8bebe00df211d4fdac3edc36cf35e1d5af42e0Mark Andrews resultFields: [{key:"title", locator:"*[local-name() ='title']"}]
5a8bebe00df211d4fdac3edc36cf35e1d5af42e0Mark Andrews <h6>Normalized data</h6>
5a8bebe00df211d4fdac3edc36cf35e1d5af42e0Mark Andrews <input type="button" id="demo_xml" value="Retrieve data">
2fff8b8280779a25fbdb891b2d3d9b435d2084f0Tatuya JINMEI 神明達哉 <div id="demo_output_xml" class="output"></div>
19bcb91965916ed8f0a47da2284ddaecce70bc69Evan Hunt<script type="text/javascript">
9c114f36dab6bc6fc024b46680cfdd246efc880cEvan HuntYUI().use("dump", "node", "datasource-io", "datasource-jsonschema", "datasource-xmlschema", function (Y) {
5a8bebe00df211d4fdac3edc36cf35e1d5af42e0Mark Andrews var myDataSourceJSON = new Y.DataSource.IO({source:"../assets/datasource/ysearch.json"}),
ffc65cc90db78a67171e3d91f63f2e92d09d2d38Evan Hunt myCallbackJSON = {
ffc65cc90db78a67171e3d91f63f2e92d09d2d38Evan Hunt success: function(e){
767c53c304b86460d72eeec7d3304172cdd904bdEvan Hunt Y.one("#demo_output_json").setContent(Y.dump(e.response));
309a3b5808b3e7666d219665c28768e5c0997f14Mark Andrews failure: function(e){
309a3b5808b3e7666d219665c28768e5c0997f14Mark Andrews Y.one("#demo_output_json").setContent("Could not retrieve data: " + e.error.message);
309a3b5808b3e7666d219665c28768e5c0997f14Mark Andrews myDataSourceJSON.plug(Y.Plugin.DataSourceJSONSchema, {
309a3b5808b3e7666d219665c28768e5c0997f14Mark Andrews resultListLocator: "ResultSet.Result",
309a3b5808b3e7666d219665c28768e5c0997f14Mark Andrews resultFields: ["Title"]
309a3b5808b3e7666d219665c28768e5c0997f14Mark Andrews Y.on("click", function(e){
309a3b5808b3e7666d219665c28768e5c0997f14Mark Andrews request:"?output=json",
309a3b5808b3e7666d219665c28768e5c0997f14Mark Andrews callback:myCallbackJSON
e80b69327290953b825c7778d8de9d314bed6198Mark Andrews }, "#demo_json");
e80b69327290953b825c7778d8de9d314bed6198Mark Andrews var myDataSourceXML = new Y.DataSource.IO({source:"../assets/datasource/ysearch.xml"}),
e80b69327290953b825c7778d8de9d314bed6198Mark Andrews myCallbackXML = {
e80b69327290953b825c7778d8de9d314bed6198Mark Andrews success: function(e){
e80b69327290953b825c7778d8de9d314bed6198Mark Andrews Y.one("#demo_output_xml").setContent(Y.dump(e.response).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"));
e80b69327290953b825c7778d8de9d314bed6198Mark Andrews failure: function(e){
309a3b5808b3e7666d219665c28768e5c0997f14Mark Andrews Y.one("#demo_output_xml").setContent("Could not retrieve data: " + e.error.message);
309a3b5808b3e7666d219665c28768e5c0997f14Mark Andrews myDataSourceXML.plug(Y.Plugin.DataSourceXMLSchema, {
309a3b5808b3e7666d219665c28768e5c0997f14Mark Andrews resultListLocator: "result",
309a3b5808b3e7666d219665c28768e5c0997f14Mark Andrews resultFields: [{key:"title", locator:"*[local-name() ='title']"}]
309a3b5808b3e7666d219665c28768e5c0997f14Mark Andrews Y.on("click", function(e){
309a3b5808b3e7666d219665c28768e5c0997f14Mark Andrews request:"?output=xml",
309a3b5808b3e7666d219665c28768e5c0997f14Mark Andrews callback:myCallbackXML
309a3b5808b3e7666d219665c28768e5c0997f14Mark Andrews }, "#demo_xml");