1. #1
    Ext JS Premium Member
    Join Date
    Sep 2010
    Posts
    65
    Vote Rating
    0
    djkraz is on a distinguished road

      0  

    Default problem with attribute mapping in xml reader?

    problem with attribute mapping in xml reader?


    I have read through all the docs and examples and I believe I am doing everything correctly but still I get an error when trying to map to an attribute in an XmlReader. I have stepped through the code and the records are being returned correctly but I can't seem to return an attribute from root.querySelectorAll(q[i]) where q[i] = "@guid" and root = "<clip guid="x">". When i let it run on it's own i get "DOM Exception 12: An invalid or illegal string was specified" and when I step through it I get "SYNTAX_ERR: DOM Exception 12". I have searched everywhere to an alternative for selecting an attribute and I can't find anything.

    Here is my code:
    PHP Code:
    Ext.setup({
        
    fullscreentrue,
        
    glossOnIconfalse,
        
    onReady: function() {
            var 
    model Ext.regModel('model', {
                
    fields: [
                       { 
    name'guid'mapping'@guid'type'string' }
                   ]
            });

            var 
    store = new Ext.data.XmlStore({
                
    model'model',
                
    autoLoadtrue,
                
    proxy: {
                    
    type'ajax',
                    
    url'/touch/newsfeed.xml',
                    
    reader: new Ext.data.XmlReader({
                        
    type'xml',
                        
    record'clip'
                    
    })
                }
            });

            
    store.load();

            var 
    tpl = new Ext.XTemplate(
                
    '<tpl for=".">',
                    
    '<div class="thumb-wrap" id="{guid}">',
                    
    '<div class="thumb">test</div>',
                
    '</tpl>',
                
    '<div class="x-clear"></div>'
            
    );

            var 
    panel = new Ext.Panel({
                
    id'images-view',
                
    fullscreentrue,
                
    layout'fit',
                
    items: [new Ext.DataView({
                    
    storestore,
                    
    tpltpl,
                    
    autoHeighttrue,
                    
    multiSelecttrue,
                    
    overClass'x-view-over',
                    
    itemSelector'div.thumb-wrap',
                    
    emptyText'No images to display'
                
    })]
            });
        }
    }); 
    and here is my xml:
    HTML Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <cps success="true">
        <clip guid="b4e889ba-efff-4d87-a729-776e0e51ec12"></clip>
        <clip guid="07f62c6e-6107-4e60-ae01-eb1b74bfa1b4"></clip>
        <clip guid="083c3536-e210-49d8-8eb9-057eeb8c4119"></clip>
        <clip guid="f87c4c6b-2184-4c6b-8277-28e6ca1f5f6e"></clip>
        <clip guid="9348a0a4-c09a-419c-9932-df4cdd59aa04"></clip>
    </cps>
    Thanks in advance!

  2. #2
    Sencha User
    Join Date
    Mar 2010
    Posts
    28
    Vote Rating
    0
    Shane F is on a distinguished road

      0  

    Default


    Getting the same error.

  3. #3
    Sencha User
    Join Date
    Apr 2010
    Location
    Greece
    Posts
    30
    Vote Rating
    0
    Theodosis is on a distinguished road

      0  

    Default


    I had the same problem, and fount out that the xml reader cannot do that at the moment. So, I wrote the following code, that fixes that

    Code:
    Ext.override( Ext.data.XmlReader, {
        createAccessor: function() {
            var selectValue = function(key, root, defaultValue){
    			if( key == '#' ){
    				return root.tagName;
    			}
    			if( key.indexOf( '@' ) != -1 ){
    				var property = key.split( '@' )[ 1 ];
    				key = key.split( '@' )[ 0 ];
    			}
    			var val;
    			if( key.length ){
    				var node = Ext.DomQuery.selectNode(key, root);
    				if( node && node.firstChild ){
    					node = node.firstChild;
    				}
    			}
    			else{
    				var node = root;
    			}
                if(node){
    				if( typeof( node.getAttribute ) != 'undefined' && typeof( property ) != 'undefined' ){
    					val = node.getAttribute( property );
    				}
    				else{
    					val = node.nodeValue;
    				}
                }
                return Ext.isEmpty(val) ? defaultValue : val;
            };
    
            return function(key) {
                var fn;
    
                if (key == this.totalProperty) {
                    fn = function(root, defaultValue) {
                        var value = selectValue(key, root, defaultValue);
                        return parseFloat(value);
                    };
                }
    
                else if (key == this.successProperty) {
                    fn = function(root, defaultValue) {
                        var value = selectValue(key, root, true);
                        return (value !== false && value !== 'false');
                    };
                }
    
                else {
                    fn = function(root, defaultValue) {
                        return selectValue(key, root, defaultValue);
                    };
                }
    
                return fn;
            };
        }(),
    });
    You shound run that right after the ext-touch.js
    I am not 100% sure that it works in all ocasions. But untill now no errors occured from that...

  4. #4
    Ext User
    Join Date
    Dec 2010
    Posts
    9
    Vote Rating
    0
    jkoutavas is on a distinguished road

      0  

    Default


    I'm seeing the same issue as well. The patch given above is a good workaround.

    I'm bumping this up as a entry in the Bugs section of the forum. Follow-ups to this topic should probably end up here: http://www.sencha.com/forum/showthre...168#post561168

  5. #5
    Sencha - Community Support Team edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Vote Rating
    7
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default


    I can't reproduce this in my unit tests - see http://www.sencha.com/forum/showthre...g-in-XMLReader to track the ticket
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

  6. #6
    Sencha User
    Join Date
    Feb 2008
    Posts
    12
    Vote Rating
    0
    kalbster is on a distinguished road

      0  

    Default workaround

    workaround


    the workaround posted above worked for me. Thanks.

  7. #7
    Sencha User
    Join Date
    Apr 2011
    Location
    Cologne, Germany
    Posts
    6
    Vote Rating
    0
    der_user is on a distinguished road

      0  

    Default Thanks

    Thanks


    The workaround worked for me, too. Thanks!

  8. #8
    Sencha User
    Join Date
    Aug 2010
    Posts
    303
    Vote Rating
    3
    steve1964 is on a distinguished road

      0  

    Default


    Worked for me too, thanks for the override.

Similar Threads

  1. XmlReader mapping to XML attribute
    By Davi Baldin in forum Ext 1.x: Help & Discussion
    Replies: 7
    Last Post: 16 Jan 2012, 4:34 PM
  2. Problem reading success attribute on store using xml reader
    By fuzzy_chris in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 16 Aug 2010, 2:25 AM
  3. XML Mapping Problem
    By dprajasekhar in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 5 Sep 2009, 8:53 AM
  4. XML tag mapping problem
    By max_zoro in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 15 May 2009, 8:02 AM
  5. XML Reader mapping to the same node
    By ameetp in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 23 Mar 2009, 1:04 AM

Thread Participants: 7

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi