datasource-xmlschema-debug.js revision 2634b0e23224a943745ebee1c4b016a207ab0564
150N/AYUI.add('datasource-xmlschema', function(Y) {
150N/A
150N/A/**
257N/A * Extends DataSource with schema-parsing on XML data.
257N/A *
257N/A * @module datasource
257N/A * @submodule datasource-xmlschema
257N/A */
257N/A
257N/A/**
150N/A * Adds schema-parsing to the YUI DataSource utility.
257N/A * @class DataSourceXMLSchema
257N/A * @extends Plugin
257N/A */
200N/Avar DataSourceXMLSchema = function() {
150N/A DataSourceXMLSchema.superclass.constructor.apply(this, arguments);
210N/A};
150N/A
150N/AY.mix(DataSourceXMLSchema, {
150N/A /**
150N/A * The namespace for the plugin. This will be the property on the host which
150N/A * references the plugin instance.
150N/A *
150N/A * @property NS
150N/A * @type String
150N/A * @static
150N/A * @final
150N/A * @value "schema"
150N/A */
150N/A NS: "schema",
150N/A
150N/A /**
150N/A * Class name.
200N/A *
200N/A * @property NAME
200N/A * @type String
200N/A * @static
200N/A * @final
200N/A * @value "DataSourceXMLSchema"
200N/A */
200N/A NAME: "DataSourceXMLSchema",
200N/A
200N/A /////////////////////////////////////////////////////////////////////////////
200N/A //
200N/A // DataSourceXMLSchema Attributes
150N/A //
210N/A /////////////////////////////////////////////////////////////////////////////
210N/A
210N/A ATTRS: {
210N/A schema: {
210N/A //value: {}
210N/A }
210N/A }
210N/A});
210N/A
210N/AY.extend(DataSourceXMLSchema, Y.Plugin.Base, {
210N/A /**
210N/A * Internal init() handler.
210N/A *
210N/A * @method initializer
210N/A * @param config {Object} Config object.
210N/A * @private
210N/A */
210N/A initializer: function(config) {
210N/A this.doBefore("_defDataFn", this._beforeDefDataFn);
210N/A },
257N/A
257N/A /**
257N/A * Parses raw data into a normalized response.
257N/A *
257N/A * @method _beforeDefDataFn
257N/A * <dl>
257N/A * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
257N/A * <dt>request (Object)</dt> <dd>The request.</dd>
257N/A * <dt>callback (Object)</dt> <dd>The callback object with the following properties:
257N/A * <dl>
257N/A * <dt>success (Function)</dt> <dd>Success handler.</dd>
257N/A * <dt>failure (Function)</dt> <dd>Failure handler.</dd>
257N/A * <dt>scope (Object)</dt> <dd>Execution context.</dd>
257N/A * </dl>
257N/A * </dd>
257N/A * <dt>data (Object)</dt> <dd>Raw data.</dd>
257N/A * </dl>
257N/A * @protected
257N/A */
257N/A _beforeDefDataFn: function(e) {
257N/A var data = ((this.get("host") instanceof Y.DataSource.XHR) && e.data.responseXML && (e.data.responseXML.nodeType === 9)) ? e.data.responseXML : e.data,
257N/A response = Y.DataSchema.XML.apply(this.get("schema"), data);
257N/A
257N/A // Default
257N/A if(!response) {
257N/A response = {
257N/A meta: {},
257N/A results: data
257N/A };
257N/A }
257N/A
257N/A this.get("host").fire("response", Y.mix({response:response}, e));
150N/A return new Y.Do.Halt("DataSourceXMLSchema plugin halted _defDataFn");
}
});
Y.namespace('plugin').DataSourceXMLSchema = DataSourceXMLSchema;
}, '@VERSION@' ,{requires:['plugin', 'datasource-local', 'dataschema-xml']});