Creating And Resolving Namespaces

The steps to create and resolve namespaces are contained in the namespace and resolve methods. We have already described how the resolve method works by delegating most of the work to the traverse method. The namespace method also delegates to the traverse method; however, it passes a

01: namespace: function(name) {
02: return this.traverse(name, function(name, part, current) {
03: if ( !current[part] ) { 04: current[part] = new XNamespace(part, current); 05: } 06: else if ( !(current[part] instanceof XNamespace) ) { 07: throw part + " is not a valid namespace."; 08: } 09: return current[part]; 10: }); 11: },

Previous Up Next