1 /** 2 * @fileoverview A class representing the element node of the 3 * XDM interface. 4 */ 5 6 goog.provide('xrx.node.Element'); 7 8 9 10 goog.require('xrx.node'); 11 goog.require('xrx.node.Attribute'); 12 goog.require('xrx.token'); 13 goog.require('xrx.xpath.NodeSet'); 14 15 16 17 /** 18 * @constructor 19 */ 20 xrx.node.Element = function(pilot, token, instance) { 21 goog.base(this, pilot, xrx.node.ELEMENT, token, instance); 22 }; 23 goog.inherits(xrx.node.Element, xrx.node); 24 25 26 xrx.node.Element.prototype.accAttributes = function() {}; 27 xrx.node.Element.prototype.accBaseUri = function() {}; 28 xrx.node.Element.prototype.accChildren = function() {}; 29 xrx.node.Element.prototype.accDocumentUri = function() {}; 30 xrx.node.Element.prototype.accIsId = function() {}; 31 xrx.node.Element.prototype.accIsIdrefs = function() {}; 32 xrx.node.Element.prototype.accNamespaceNodes = function() {}; 33 xrx.node.Element.prototype.accNilled = function() {}; 34 xrx.node.Element.prototype.accNodeKind = function() {}; 35 xrx.node.Element.prototype.accNodeName = function() {}; 36 xrx.node.Element.prototype.accParent = function() {}; 37 xrx.node.Element.prototype.accStringValue = function() {}; 38 xrx.node.Element.prototype.accTypeName = function() {}; 39 xrx.node.Element.prototype.accTypedValue = function() {}; 40 xrx.node.Element.prototype.accUnparsedEntityPublicId = function() {}; 41 xrx.node.Element.prototype.accUnparsedEntitySystemId = function() {}; 42 43 44 /** 45 * @override 46 */ 47 xrx.node.Element.prototype.expandedName = function() { 48 var pilot = this.pilot_; 49 return '' + pilot.xml(pilot.tagName(this.token_, this.token_)); 50 }; 51 52 53 54 /** 55 * @override 56 */ 57 xrx.node.Element.prototype.namespaceUri = function() { 58 return undefined; 59 }; 60 61 62 63 64 /** 65 * @override 66 */ 67 xrx.node.Element.prototype.getAttributeNodes = function(test) { 68 var nodeset = new xrx.xpath.NodeSet(); 69 var stream = this.pilot_.stream(); 70 var label = this.label().clone(); 71 label.child(); 72 var attribute = new xrx.token.Attribute(label); 73 74 for(;;) { 75 var location = stream.attrName(this.token_.xml(this.pilot_.xml()), 76 attribute.label().last(), attribute.offset()); 77 if (!location) break; 78 attribute.offset(location.offset); 79 attribute.length(location.length); 80 var node = new xrx.node.Attribute(this.pilot_, attribute, this, this.instance_) 81 if (test.matches(node)) { 82 nodeset.add(node); 83 break; 84 } 85 attribute.label().nextSibling(); 86 } 87 return nodeset; 88 }; 89