- The Book of Dojo
- Quick Installation
- Hello World
- Debugging Tutorial
- Introduction
- Part 1: Life With Dojo
- Part 2: Dijit
- Part 3: JavaScript With Dojo and Dijit
- Part 4: Testing, Tuning and Debugging
- Part 5: DojoX
- The Dojo Book, 0.4
dojox.data.OpmlStore
Submitted by leesakcp on Fri, 07/13/2007 - 21:14.
OpmlStore
is a simple read-only store provided by Dojo and contained in the DojoX project. OpmlStore
is a read interface to work with Opml formatted XML files. Similar to ItemFileReadStore
, OpmlStore
reads the contents from an http endpoint or a browser DOM object that contains Opml formatted data.
The following dojo.data APIs are implemented by OpmlStore
- dojo.data.api.Read
- dojo.data.api.Identity
The following example shows an Opml data source:
geography.opml 2006-11-10 2006-11-13 Magellan, Ferdinand
Note: An item in OpmlStore
is an
entry. The atributes defined in the
tag make up the attributes that are exposed for that item. Any child items (nested
tags) are accessable using the special attribute children
.
Constructor Parameters
The constructor for OpmlStore
takes the following possible parameters in its keyword args:
- url
- The URL from which to load the Opmldata. This is optional.
- data
- The raw Opml DOM that represents the stores contents as defined by the previous structure. This is optional.
- label
- A string that identifies which column to treat as the human-readable label. It must match one of the attribute names in the
ags for it to be effective.
Query Syntax
The fetch method query syntax for OpmlStore
is simple and straightforward. It allows a list of attributes to match against in an AND fashion, just like ItemFileReadStore
. For example, the following query object locates all items that have attributes of those names that match both of those values:
{ foo:"bar", bit:"bite"}
Note that OpmlStore
supports the use of wild cards (multi-character * and single character ?) in its attribute value matching.
Examples
To find all items with attribute foo
bar
, the query would be:
{ foo:"bar*"}
To find all items with attribute foo
that value ends with ar
, and ignoring only the first character, the query would be:
{ foo:"?ar"}
NOTE: Other stores should follow the same semantics in defining queries for consistency.
Usage Examples
For these examples, we'll assume a datasource as defined by the example data format in this page.
Example 1: Query for all continents starting with A
var store = new dojox.data.OpmlStore({url: "grography.xml", label: "Text"}); var gotContinents = function(items, request){ for (var i = 0; i < items.length; i++){ var item = items[i]; console.log("Located continent: " + store.getLabel(item); } } var request = store.fetch({query: {text: "A*", type: "continent"}, onComplete: gotContinents});
Example 2: Query for all continents starting with A
, case insensitively
var store = new dojox.data.OpmlStore({url: "grography.xml", label: "Text"}); var gotContinents = function(items, request){ for (var i = 0; i < items.length; i++){ var item = items[i]; console.log("Located continent: " + store.getLabel(item); } } var request = store.fetch({query: {text: "a*", type: "continent"}, queryOptions: {ignoreCase: true}, onComplete: gotContinents});
Further Examples
For further examples refer to the test cases provided in dojox.data.tests
.
- Printer-friendly version
- Login or register to post comments
- Unsubscribe post