Results 1 to 5 of 5

Thread: xml namespaces

  1. #1
    Sencha User
    Join Date
    Feb 2008
    Posts
    105

    Default xml namespaces

    Hi

    Before Extjs I'm using jQuery and I've partialy added xml name space support
    How Extjs support xmlNS ??

    I've there usages
    Code:
    $('prfx:tag') //for get prefixed tags
    $(':NS(my.urn, tag)') //for get tags defined on my.urn name space.
    the first call return only prfx:tag tags
    the second return a pr

  2. #2
    Sencha User
    Join Date
    Feb 2008
    Posts
    105

    Thumbs up

    Hi

    i've looking Ext.DomQuery.js and does not support dom2 namespaces

    I've change somme lines
    adding \! to support tag selector prfx!tag
    Code:
    79     var modeRe = /^(\s?[\/>+~\!]\s?|\s|$)/;
    80    var tagTokenRe = /^(#)?([\w\!-\*]+)/;
    convert ! to : for tagName selector
    Code:
    152        tagName = tagName.replace('!',':');
    add : support on attribute
    Code:
    576                re: /^(?:([\[\{])(?:@)?(([\w-]+:)?([\w-]+))\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
    577                select: 'n = byAttribute(n, "{2}", "{6}", "{5}", "{1}");'
    now you can select node like
    Code:
        var E1 = Ext.select('[@id=dock2]');
        var E2 = Ext.select('[@fast:class=Switcher]');
        var E3 = Ext.select('body');
        var E4 = Ext.select('fast!block');
        var E5 = Ext.select('fast!block[@fast:class=Switcher]');
    I don't ave added urn redirect namespace support.


    By
    A+JYT

  3. #3
    Sencha User
    Join Date
    Feb 2008
    Posts
    105

    Default

    Hi

    i've added namspace support

    I've change somme lines
    change tagTokenRe (the previus change of nodeRe is not necessairy line 79)
    Code:
    79    var modeRe = /^(\s?[\/>+~]\s?|\s|$)/;
    80    var tagTokenRe = /^(#)?((((\([\w-\*:\.]+\))|([\w-\*]+))!)?([\w-\*]+))/;
    add namespace table initialiation
    Code:
    82    if ('undefined' == typeof(document.namespaces)) {//init global namespaces array if undefined
    83      document.namespaces = new Array();
    83      attibutes=document.documentElement.attributes;
    84      i = 0;
    85      for (x = 0; x < attibutes.length; x++) {
    86         attr = attibutes[x];
    87         if (/xmlns:/.test(attr.nodeName)) {
    88            var matches = attr.nodeName.split(/:/);
    89            var namespace = {
    90            name: matches[1],
    91            urn: attr.value};
    92            document.namespaces[i++] = namespace;
    93         }
    94      }
    95    }
    convert ! to : for tagName selector and add namespace search
    Code:
    168        tagName = tagName.replace('!',':');
    169        var am = tagName.match (/(\((.*)\)):(.*)/);
    170        if (am){
    171            var namespace = Ext.DomQuery.getNS(am[2]);
    172            if (namespace) {
    173                tagName = namespace.name+':'+ am[3];
    174            }
    175        }
    add : support on attribute
    Code:
    616                re: /^(?:([\[\{])(?:@)?((((\([\w-\/\:\.]+\))|([\w-]+)):)?([\w-]+))\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
    617                select: 'n = byAttribute(n, "{2}", "{9}", "{8}", "{1}");'
    and on buAttribute finction
    Code:
    268        var am = attr.match (/(\((.*)\)):(.*)/);
    269        if (am){
    270            var namespace = Ext.DomQuery.getNS(am[2]);
    271            if (namespace) {
    272                attr = namespace.name+':'+ am[3];
    273            }
    274        }
    now you can select node like
    Code:
    <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:fast="urn:org.jquery.fast">
    ....
        <div fast:class="Switcher">....
    </html>
    Code:
        var E1 = Ext.select('[@id=dock2]');
        var E2 = Ext.select('[@fast:class=Switcher]');
        var E3 = Ext.select('body');
        var E4 = Ext.select('fast!block');
        var E5 = Ext.select('fast!block[@fast:class=Switcher]');
        var E6 = Ext.select('[@(urn:org.jquery.fast):class=Switcher]');
        var E7 = Ext.select('(urn:org.jquery.fast)!block');
        var E8 = Ext.select('(urn:org.jquery.fast)!block[@(urn:org.jquery.fast):class=Switcher]');

    By
    A+JYT

  4. #4
    Sencha User
    Join Date
    Feb 2008
    Posts
    105

    Default

    Hi
    for tag in namespace i've choose ! selector like
    Code:
        var E4 = Ext.select('fast!block');
    but this choise introduce an error (all html comment are acceted as tag)

    I've change it to @ selector
    Code:
    80    var tagTokenRe = /^(#)?((((\([\w-\*:\.]+\))|([\w-\*]+))@)?([\w-\*]+))/;
    so in the byAttribute function for compatibilty with IE change the lines
    Code:
    288                var sp = attr.match (/(.*):(.*)/);
    289                if (sp) {
    290                    a= Ext.get(ci).getAttributeNS(sp[1],sp[2])
    291                } else {
    292                    a = ci.getAttribute(attr);
    293                }
    By

  5. #5
    Sencha User
    Join Date
    Feb 2008
    Posts
    105

    Default

    Hi
    Ext implement getAttributeNS(ns, attr) to get an namespace attribut. but this method return an attribute was not in name space.

    the xmlnamespaces are defined for define many attributes or tags was have same name for different use.
    [code]<input type="text" xmlns:check="urn:org.verify" check:type="date" />[code]
    the attribute type is defined on html global namspace and on org.verify first for displayong and text box second for verify the value.

    the DOM2 sp
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •