Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / src / data / XmlStore.js
1 /*
2
3 This file is part of Ext JS 4
4
5 Copyright (c) 2011 Sencha Inc
6
7 Contact:  http://www.sencha.com/contact
8
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
11
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
13
14 */
15 /**
16  * @author Ed Spencer
17  * @class Ext.data.XmlStore
18  * @extends Ext.data.Store
19  * @private
20  * @ignore
21  * <p>Small helper class to make creating {@link Ext.data.Store}s from XML data easier.
22  * A XmlStore will be automatically configured with a {@link Ext.data.reader.Xml}.</p>
23  * <p>A store configuration would be something like:<pre><code>
24 var store = new Ext.data.XmlStore({
25     // store configs
26     autoDestroy: true,
27     storeId: 'myStore',
28     url: 'sheldon.xml', // automatically configures a HttpProxy
29     // reader configs
30     record: 'Item', // records will have an "Item" tag
31     idPath: 'ASIN',
32     totalRecords: '@TotalResults'
33     fields: [
34         // set up the fields mapping into the xml doc
35         // The first needs mapping, the others are very basic
36         {name: 'Author', mapping: 'ItemAttributes > Author'},
37         'Title', 'Manufacturer', 'ProductGroup'
38     ]
39 });
40  * </code></pre></p>
41  * <p>This store is configured to consume a returned object of the form:<pre><code>
42 &#60?xml version="1.0" encoding="UTF-8"?>
43 &#60ItemSearchResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2009-05-15">
44     &#60Items>
45         &#60Request>
46             &#60IsValid>True&#60/IsValid>
47             &#60ItemSearchRequest>
48                 &#60Author>Sidney Sheldon&#60/Author>
49                 &#60SearchIndex>Books&#60/SearchIndex>
50             &#60/ItemSearchRequest>
51         &#60/Request>
52         &#60TotalResults>203&#60/TotalResults>
53         &#60TotalPages>21&#60/TotalPages>
54         &#60Item>
55             &#60ASIN>0446355453&#60/ASIN>
56             &#60DetailPageURL>
57                 http://www.amazon.com/
58             &#60/DetailPageURL>
59             &#60ItemAttributes>
60                 &#60Author>Sidney Sheldon&#60/Author>
61                 &#60Manufacturer>Warner Books&#60/Manufacturer>
62                 &#60ProductGroup>Book&#60/ProductGroup>
63                 &#60Title>Master of the Game&#60/Title>
64             &#60/ItemAttributes>
65         &#60/Item>
66     &#60/Items>
67 &#60/ItemSearchResponse>
68  * </code></pre>
69  * An object literal of this form could also be used as the {@link #data} config option.</p>
70  * <p><b>Note:</b> This class accepts all of the configuration options of
71  * <b>{@link Ext.data.reader.Xml XmlReader}</b>.</p>
72  * @xtype xmlstore
73  */
74 Ext.define('Ext.data.XmlStore', {
75     extend: 'Ext.data.Store',
76     alternateClassName: 'Ext.data.XmlStore',
77     alias: 'store.xml',
78
79     /**
80      * @cfg {Ext.data.DataReader} reader @hide
81      */
82     constructor: function(config){
83         config = config || {};
84         config = config || {};
85
86         Ext.applyIf(config, {
87             proxy: {
88                 type: 'ajax',
89                 reader: 'xml',
90                 writer: 'xml'
91             }
92         });
93
94         this.callParent([config]);
95     }
96 });
97