[xmljs-users] RE: xmljs-users digest, Vol 1 #12 - 2 msgs
Brought to you by:
djoham,
witchhunter
From: James S. E. <jam...@co...> - 2004-02-24 17:21:01
|
The way I avoid that kind of problem is to write empty nodes as if they weren't empty: <ZIPCODE id="12345"></ZIPCODE> Just out of curiosity, why don't you use the ZIP code itself as the content instead of as an attribute value? <ZIPCODE>12345</ZIPCODE> -----Original Message----- From: xml...@li... [mailto:xml...@li...]On Behalf Of xml...@li... Sent: Tuesday, February 24, 2004 11:09 AM To: xml...@li... Subject: xmljs-users digest, Vol 1 #12 - 2 msgs Send xmljs-users mailing list submissions to xml...@li... To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/xmljs-users or, via email, send a message with subject or body 'help' to xml...@li... You can reach the person managing the list at xml...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of xmljs-users digest..." Today's Topics: 1. Empty Nodes (Thomas Schletter) 2. Re: Empty Nodes (David Joham) --__--__-- Message: 1 From: Thomas Schletter <tho...@gm...> Reply-To: tho...@fr... To: xml...@li... Date: Tue, 24 Feb 2004 11:14:10 +0100 Subject: [xmljs-users] Empty Nodes Hi I tried to parse nodes whitout text-content with the w3cdom-parser, until here there is no problem. When I try to get these empty nodes (to get the attributes) i can't access them, these nodes are not in the dom-tree. example xml taken from the sample-section and modified: <?xml version="1.0"?> <CONTACTS> <CONTACT id="4" > <FIRSTNAME> Kelly </FIRSTNAME> <LASTNAME> VanMcIntyre </LASTNAME> <ADDRESS> 92535 Highway 6 </ADDRESS> <CITY> Somewhere </CITY> <STATE> AZ </STATE> <ZIPCODE id="12345" /> </CONTACT> </CONTACTS> The Node "ZIPCODE" is not present in the dom-tree. Is there a way to get these Nodes? MfG Thomas Schletter -- Mail: tho...@gm... Tel: 0049 371/656 10654 --__--__-- Message: 2 Date: Tue, 24 Feb 2004 09:05:09 -0800 (PST) From: David Joham <dj...@ya...> Subject: Re: [xmljs-users] Empty Nodes To: tho...@fr..., xml...@li... --0-47996811-1077642309=:16634 Content-Type: text/plain; charset=us-ascii Content-Id: Content-Disposition: inline Hi Thomas, I think you're running into a known issue with the 3.0 parser. I have attached a new version of xmlw3cdom that should fix the problem for you. It's part of the 3.1 release which should come out sometime in late March or Early April. Please let me know if this doesn't fix the problem for you... David --- Thomas Schletter <tho...@gm...> wrote: > Hi > > I tried to parse nodes whitout text-content with the w3cdom-parser, until here > there is no problem. When I try to get these empty nodes (to get the > attributes) i can't access them, these nodes are not in the dom-tree. > > example xml taken from the sample-section and modified: > > <?xml version="1.0"?> > <CONTACTS> > <CONTACT id="4" > > <FIRSTNAME> > Kelly > </FIRSTNAME> > <LASTNAME> > VanMcIntyre > </LASTNAME> > <ADDRESS> > 92535 Highway 6 > </ADDRESS> > <CITY> > Somewhere > </CITY> > <STATE> > AZ > </STATE> > <ZIPCODE id="12345" /> > </CONTACT> > </CONTACTS> > > The Node "ZIPCODE" is not present in the dom-tree. Is there a way to get these > Nodes? > > > MfG Thomas Schletter > > -- > Mail: tho...@gm... > Tel: 0049 371/656 10654 > > > > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users __________________________________ Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. http://antispam.yahoo.com/tools --0-47996811-1077642309=:16634 Content-Type: text/plain; name="xmlw3cdom.js" Content-Description: xmlw3cdom.js Content-Disposition: inline; filename="xmlw3cdom.js" // ========================================================================= // // xmlw3cdom.js - a W3C compliant DOM parser for XML for <SCRIPT> // // version 3.1 // // ========================================================================= // // Copyright (C) 2002, 2003 Jon van Noort (jo...@we...), David Joham (dj...@ya...) and Scott Severtson // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // visit the XML for <SCRIPT> home page at xmljs.sourceforge.net // // Contains text (used within comments to methods) from the // XML Path Language (XPath) Version 1.0 W3C Recommendation // Copyright © 16 November 1999 World Wide Web Consortium, // (Massachusetts Institute of Technology, // European Research Consortium for Informatics and Mathematics, Keio University). // All Rights Reserved. // (see: http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/) /** * @function addClass - add new className to classCollection * * @author Jon van Noort (jo...@we...) * * @param classCollectionStr : string - list of existing class names * (separated and top and tailed with '|'s) * @param newClass : string - new class name to add * * @return : string - the new classCollection, with new className appended, * (separated and top and tailed with '|'s) */ function addClass(classCollectionStr, newClass) { if (classCollectionStr) { if (classCollectionStr.indexOf("|"+ newClass +"|") < 0) { classCollectionStr += newClass + "|"; } } else { classCollectionStr = "|"+ newClass + "|"; } return classCollectionStr; } /** * @class DOMException - raised when an operation is impossible to perform * * @author Jon van Noort (jo...@we...) * * @param code : int - the exception code (one of the DOMException constants) */ DOMException = function(code) { this._class = addClass(this._class, "DOMException"); this.code = code; }; // DOMException constants // Introduced in DOM Level 1: DOMException.INDEX_SIZE_ERR = 1; DOMException.DOMSTRING_SIZE_ERR = 2; DOMException.HIERARCHY_REQUEST_ERR = 3; DOMException.WRONG_DOCUMENT_ERR = 4; DOMException.INVALID_CHARACTER_ERR = 5; DOMException.NO_DATA_ALLOWED_ERR = 6; DOMException.NO_MODIFICATION_ALLOWED_ERR = 7; DOMException.NOT_FOUND_ERR = 8; DOMException.NOT_SUPPORTED_ERR = 9; DOMException.INUSE_ATTRIBUTE_ERR = 10; // Introduced in DOM Level 2: DOMException.INVALID_STATE_ERR = 11; DOMException.SYNTAX_ERR = 12; DOMException.INVALID_MODIFICATION_ERR = 13; DOMException.NAMESPACE_ERR = 14; DOMException.INVALID_ACCESS_ERR = 15; /** * @class DOMImplementation - provides a number of methods for performing operations * that are independent of any particular instance of the document object model. * * @author Jon van Noort (jo...@we...) */ DOMImplementation = function() { this._class = addClass(this._class, "DOMImplementation"); this._p = null; this.preserveWhiteSpace = false; // by default, ignore whitespace this.namespaceAware = true; // by default, handle namespaces this.errorChecking = true; // by default, test for exceptions }; /** * @method DOMImplementation.hasFeature - Test if the DOM implementation implements a specific feature * * @author Jon van Noort (jo...@we...) * * @param feature : string - The package name of the feature to test. the legal only values are "XML" and "CORE" (case-insensitive). * @param version : string - This is the version number of the package name to test. In Level 1, this is the string "1.0". * * @return : boolean */ DOMImplementation.prototype.hasFeature = function DOMImplementation_hasFeature(feature, version) { var ret = false; if (feature.toLowerCase() == "xml") { ret = (!version || (version == "1.0") || (version == "2.0")); } else if (feature.toLowerCase() == "core") { ret = (!version || (version == "2.0")); } return ret; }; /** * @method DOMImplementation.loadXML - parse XML string * * @author Jon van Noort (jo...@we...), David Joham (dj...@ya...) and Scott Severtson * * @param xmlStr : string - the XML string * * @return : DOMDocument */ DOMImplementation.prototype.loadXML = function DOMImplementation_loadXML(xmlStr) { // create SAX Parser var parser; try { parser = new XMLP(xmlStr); } catch (e) { alert("Error Creating the SAX Parser. Did you include xmlsax.js or tinyxmlsax.js in your web page?\nThe SAX parser is needed to populate XML for <SCRIPT>'s W3C DOM Parser with data."); } // create DOM Document var doc = new DOMDocument(this); // populate Document with Parsed Nodes this._parseLoop(doc, parser); // set parseComplete flag, (Some validation Rules are relaxed if this is false) doc._parseComplete = true; return doc; }; /** * @method DOMImplementation.translateErrCode - convert DOMException Code * to human readable error message; * * @author Jon van Noort (jo...@we...) * * @param code : int - the DOMException code * * @return : string - the human readbale error message */ DOMImplementation.prototype.translateErrCode = function DOMImplementation_translateErrCode(code) { var msg = ""; switch (code) { case DOMException.INDEX_SIZE_ERR : // 1 msg = "INDEX_SIZE_ERR: Index out of bounds"; break; case DOMException.DOMSTRING_SIZE_ERR : // 2 msg = "DOMSTRING_SIZE_ERR: The resulting string is too long to fit in a DOMString"; break; case DOMException.HIERARCHY_REQUEST_ERR : // 3 msg = "HIERARCHY_REQUEST_ERR: The Node can not be inserted at this location"; break; case DOMException.WRONG_DOCUMENT_ERR : // 4 msg = "WRONG_DOCUMENT_ERR: The source and the destination Documents are not the same"; break; case DOMException.INVALID_CHARACTER_ERR : // 5 msg = "INVALID_CHARACTER_ERR: The string contains an invalid character"; break; case DOMException.NO_DATA_ALLOWED_ERR : // 6 msg = "NO_DATA_ALLOWED_ERR: This Node / NodeList does not support data"; break; case DOMException.NO_MODIFICATION_ALLOWED_ERR : // 7 msg = "NO_MODIFICATION_ALLOWED_ERR: This object cannot be modified"; break; case DOMException.NOT_FOUND_ERR : // 8 msg = "NOT_FOUND_ERR: The item cannot be found"; break; case DOMException.NOT_SUPPORTED_ERR : // 9 msg = "NOT_SUPPORTED_ERR: This implementation does not support function"; break; case DOMException.INUSE_ATTRIBUTE_ERR : // 10 msg = "INUSE_ATTRIBUTE_ERR: The Attribute has already been assigned to another Element"; break; // Introduced in DOM Level 2: case DOMException.INVALID_STATE_ERR : // 11 msg = "INVALID_STATE_ERR: The object is no longer usable"; break; case DOMException.SYNTAX_ERR : // 12 msg = "SYNTAX_ERR: Syntax error"; break; case DOMException.INVALID_MODIFICATION_ERR : // 13 msg = "INVALID_MODIFICATION_ERR: Cannot change the type of the object"; break; case DOMException.NAMESPACE_ERR : // 14 msg = "NAMESPACE_ERR: The namespace declaration is incorrect"; break; case DOMException.INVALID_ACCESS_ERR : // 15 msg = "INVALID_ACCESS_ERR: The object does not support this function"; break; default : msg = "UNKNOWN: Unknown Exception Code ("+ code +")"; } return msg; } /** * @method DOMImplementation._parseLoop - process SAX events * * @author Jon van Noort (jo...@we...), David Joham (dj...@ya...) and Scott Severtson * * @param doc : DOMDocument - the Document to contain the parsed XML string * @param p : XMLP - the SAX Parser * * @return : DOMDocument */ DOMImplementation.prototype._parseLoop = function DOMImplementation__parseLoop(doc, p) { var iEvt, iNode, iAttr, strName; iNodeParent = doc; var el_close_count = 0; var entitiesList = new Array(); // if namespaceAware, add default namespace if (this.namespaceAware) { var iNS = doc.createNamespace(""); // add the default-default namespace iNS.setValue("http://www.w3.org/2000/xmlns/"); doc._namespaces.setNamedItem(iNS); } // loop until SAX parser stops emitting events while(true) { // get next event iEvt = p.next(); if (iEvt == XMLP._ELM_B || iEvt == XMLP._ELM_EMP) { // Begin-Element Event var pName = p.getName(); // get the Element name pName = trim(pName, true, true); // strip spaces from Element name if (!this.namespaceAware) { iNode = doc.createElement(p.getName()); // create the Element // add attributes to Element for(var i = 0; i < p.getAttributeCount(); i++) { strName = p.getAttributeName(i); // get Attribute name iAttr = iNode.getAttributeNode(strName); // if Attribute exists, use it if(!iAttr) { iAttr = doc.createAttribute(strName); // otherwise create it } iAttr.setValue(p.getAttributeValue(i)); // set Attribute value iNode.setAttributeNode(iAttr); // attach Attribute to Element } } else { // Namespace Aware // create element (with empty namespaceURI, // resolve after namespace 'attributes' have been parsed) iNode = doc.createElementNS("", p.getName()); // duplicate ParentNode's Namespace definitions iNode._namespaces = iNodeParent._namespaces._cloneNodes(iNode); // add attributes to Element for(var i = 0; i < p.getAttributeCount(); i++) { strName = p.getAttributeName(i); // get Attribute name // if attribute is a namespace declaration if (this._isNamespaceDeclaration(strName)) { // parse Namespace Declaration var namespaceDec = this._parseNSName(strName); if (strName != "xmlns") { iNS = doc.createNamespace(strName); // define namespace } else { iNS = doc.createNamespace(""); // redefine default namespace } iNS.setValue(p.getAttributeValue(i)); // set value = namespaceURI iNode._namespaces.setNamedItem(iNS); // attach namespace to namespace collection } else { // otherwise, it is a normal attribute iAttr = iNode.getAttributeNode(strName); // if Attribute exists, use it if(!iAttr) { iAttr = doc.createAttributeNS("", strName); // otherwise create it } iAttr.setValue(p.getAttributeValue(i)); // set Attribute value iNode.setAttributeNodeNS(iAttr); // attach Attribute to Element if (this._isIdDeclaration(strName)) { iNode.id = p.getAttributeValue(i); // cache ID for getElementById() } } } // resolve namespaceURIs for this Element if (iNode._namespaces.getNamedItem(iNode.prefix)) { iNode.namespaceURI = iNode._namespaces.getNamedItem(iNode.prefix).value; } // for this Element's attributes for (var i = 0; i < iNode.attributes.length; i++) { if (iNode.attributes.item(i).prefix != "") { // attributes do not have a default namespace if (iNode._namespaces.getNamedItem(iNode.attributes.item(i).prefix)) { iNode.attributes.item(i).namespaceURI = iNode._namespaces.getNamedItem(iNode.attributes.item(i).prefix).value; } } } } // if this is the Root Element if (iNodeParent.nodeType == DOMNode.DOCUMENT_NODE) { iNodeParent.documentElement = iNode; // register this Element as the Document.documentElement } iNodeParent.appendChild(iNode); // attach Element to parentNode if (iEvt == XMLP._ELM_B) { iNodeParent = iNode; // descend one level of the DOM Tree } } else if(iEvt == XMLP._ELM_E) { // End-Element Event iNodeParent = iNodeParent.parentNode; // ascend one level of the DOM Tree } else if(iEvt == XMLP._TEXT || iEvt == XMLP._ENTITY) { // TextNode and entity Events // get Text content var pContent = p.getContent().substring(p.getContentBegin(), p.getContentEnd()); if (!this.preserveWhiteSpace) { pContent = trim(pContent, true, true); // strip whitespace pContent.replace(/ +/g, ' '); // collapse multiple spaces to 1 space } if (pContent.length > 0) { // ignore empty TextNodes var textNode = doc.createTextNode(pContent); iNodeParent.appendChild(textNode); // attach TextNode to parentNode //the sax parser breaks up text nodes when it finds an entity. For //example hello<there will fire a text, an entity and another text //this sucks for the dom parser because it looks to us in this logic //as three text nodes. I fix this by keeping track of the entity nodes //and when we're done parsing, calling normalize on their parent to //turn the multiple text nodes into one, which is what DOM users expect //the code to do this is at the bottom of this function if (iEvt == XMLP._ENTITY) { entitiesList[entitiesList.length] = textNode; } } } else if(iEvt == XMLP._PI) { // ProcessingInstruction Event // attach ProcessingInstruction to parentNode iNodeParent.appendChild(doc.createProcessingInstruction(p.getName(), p.getContent().substring(p.getContentBegin(), p.getContentEnd()))); } else if(iEvt == XMLP._CDATA) { // CDATA Event // get CDATA data pContent = p.getContent().substring(p.getContentBegin(), p.getContentEnd()); if (!this.preserveWhiteSpace) { pContent = trim(pContent, true, true); // trim whitespace pContent.replace(/ +/g, ' '); // collapse multiple spaces to 1 space } if (pContent.length > 0) { // ignore empty CDATANodes iNodeParent.appendChild(doc.createCDATASection(pContent)); // attach CDATA to parentNode } } else if(iEvt == XMLP._COMMENT) { // Comment Event // get COMMENT data var pContent = p.getContent().substring(p.getContentBegin(), p.getContentEnd()); if (!this.preserveWhiteSpace) { pContent = trim(pContent, true, true); // trim whitespace pContent.replace(/ +/g, ' '); // collapse multiple spaces to 1 space } if (pContent.length > 0) { // ignore empty CommentNodes iNodeParent.appendChild(doc.createComment(pContent)); // attach Comment to parentNode } } else if(iEvt == XMLP._DTD) { // ignore DTD events } else if(iEvt == XMLP._ERROR) { throw(new DOMException(DOMException.SYNTAX_ERR)); // alert("Fatal Error: " + p.getContent() + "\nLine: " + p.getLineNumber() + "\nColumn: " + p.getColumnNumber() + "\n"); // break; } else if(iEvt == XMLP._NONE) { // no more events if (iNodeParent == doc) { // confirm that we have recursed back up to root break; } else { throw(new DOMException(DOMException.SYNTAX_ERR)); // one or more Tags were not closed properly } } } //normalize any entities in the DOM to a single textNode var intCount = entitiesList.length; for (intLoop = 0; intLoop < intCount; intLoop++) { var entity = entitiesList[intLoop]; //its possible (if for example two entities were in the //same domnode, that the normalize on the first entitiy //will remove the parent for the second. Only do normalize //if I can find a parent node var parentNode = entity.getParentNode(); if (parentNode) { parentNode.normalize(); } } }; /** * @method DOMImplementation._isNamespaceDeclaration - Return true, if attributeName is a namespace declaration * * @author Jon van Noort (jo...@we...) * * @param attributeName : string - the attribute name * * @return : boolean */ DOMImplementation.prototype._isNamespaceDeclaration = function DOMImplementation__isNamespaceDeclaration(attributeName) { // test if attributeName is 'xmlns' return (attributeName.indexOf('xmlns') > -1); } /** * @method DOMImplementation._isIdDeclaration - Return true, if attributeName is an id declaration * * @author Jon van Noort (jo...@we...) * * @param attributeName : string - the attribute name * * @return : boolean */ DOMImplementation.prototype._isIdDeclaration = function DOMImplementation__isIdDeclaration(attributeName) { // test if attributeName is 'id' (case insensitive) return (attributeName.toLowerCase() == 'id'); } /** * @method DOMImplementation._isValidName - Return true, * if name contains no invalid characters * * @author Jon van Noort (jo...@we...) * * @param name : string - the candidate name * * @return : boolean */ DOMImplementation.prototype._isValidName = function DOMImplementation__isValidName(name) { // test if name contains only valid characters return name.match(re_validName); } re_validName = /^[a-zA-Z_:][a-zA-Z0-9\.\-_:]*$/; /** * @method DOMImplementation._isValidString - Return true, if string does not contain any illegal chars * All of the characters 0 through 31 and character 127 are nonprinting control characters. * With the exception of characters 09, 10, and 13, (Ox09, Ox0A, and Ox0D) * Note: different from _isValidName in that ValidStrings may contain spaces * * @author Jon van Noort (jo...@we...) * * @param name : string - the candidate string * * @return : boolean */ DOMImplementation.prototype._isValidString = function DOMImplementation__isValidString(name) { // test that string does not contains invalid characters return (name.search(re_invalidStringChars) < 0); } re_invalidStringChars = /\x01|\x02|\x03|\x04|\x05|\x06|\x07|\x08|\x0B|\x0C|\x0E|\x0F|\x10|\x11|\x12| \x13|\x14|\x15|\x16|\x17|\x18|\x19|\x1A|\x1B|\x1C|\x1D|\x1E|\x1F|\x7F/ /** * @method DOMImplementation._parseNSName - parse the namespace name. * if there is no colon, the * * @author Jon van Noort (jo...@we...) * * @param qualifiedName : string - The qualified name * * @return : NSName - [ * .prefix : string - The prefix part of the qname * .namespaceName : string - The namespaceURI part of the qname * ] */ DOMImplementation.prototype._parseNSName = function DOMImplementation__parseNSName(qualifiedName) { var resultNSName = new Object(); resultNSName.prefix = qualifiedName; // unless the qname has a namespaceName, the prefix is the entire String resultNSName.namespaceName = ""; // split on ':' delimPos = qualifiedName.indexOf(':'); if (delimPos > -1) { // get prefix resultNSName.prefix = qualifiedName.substring(0, delimPos); // get namespaceName resultNSName.namespaceName = qualifiedName.substring(delimPos +1, qualifiedName.length); } return resultNSName; } /** * @method DOMImplementation._parseQName - parse the qualified name * * @author Jon van Noort (jo...@we...) * * @param qualifiedName : string - The qualified name * * @return : QName */ DOMImplementation.prototype._parseQName = function DOMImplementation__parseQName(qualifiedName) { var resultQName = new Object(); resultQName.localName = qualifiedName; // unless the qname has a prefix, the local name is the entire String resultQName.prefix = ""; // split on ':' delimPos = qualifiedName.indexOf(':'); if (delimPos > -1) { // get prefix resultQName.prefix = qualifiedName.substring(0, delimPos); // get localName resultQName.localName = qualifiedName.substring(delimPos +1, qualifiedName.length); } return resultQName; } /** * @class DOMNodeList - provides the abstraction of an ordered collection of nodes * * @author Jon van Noort (jo...@we...) * * @param ownerDocument : DOMDocument - the ownerDocument * @param parentNode : DOMNode - the node that the DOMNodeList is attached to (or null) */ DOMNodeList = function(ownerDocument, parentNode) { this._class = addClass(this._class, "DOMNodeList"); this._nodes = new Array(); this.length = 0; this.parentNode = parentNode; this.ownerDocument = ownerDocument; this._readonly = false; }; /** * @method DOMNodeList.getLength - Java style gettor for .length * * @author Jon van Noort (jo...@we...) * * @return : int */ DOMNodeList.prototype.getLength = function DOMNodeList_getLength() { return this.length; }; /** * @method DOMNodeList.item - Returns the indexth item in the collection. * If index is greater than or equal to the number of nodes in the list, this returns null. * * @author Jon van Noort (jo...@we...) * * @param index : int - Index into the collection. * * @return : DOMNode - The node at the indexth position in the NodeList, or null if that is not a valid index */ DOMNodeList.prototype.item = function DOMNodeList_item(index) { var ret = null; if ((index >= 0) && (index < this._nodes.length)) { // bounds check ret = this._nodes[index]; // return selected Node } return ret; // if the index is out of bounds, default value null is returned }; /** * @method DOMNodeList._findItemIndex - find the item index of the node with the specified internal id * * @author Jon van Noort (jo...@we...) * * @param id : int - unique internal id * * @return : int */ DOMNodeList.prototype._findItemIndex = function DOMNodeList__findItemIndex(id) { var ret = -1; // test that id is valid if (id > -1) { for (var i=0; i<this._nodes.length; i++) { // compare id to each node's _id if (this._nodes[i]._id == id) { // found it! ret = i; break; } } } return ret; // if node is not found, default value -1 is returned }; /** * @method DOMNodeList._insertBefore - insert the specified Node into the NodeList before the specified index * Used by DOMNode.insertBefore(). Note: DOMNode.insertBefore() is responsible for Node Pointer surgery * DOMNodeList._insertBefore() simply modifies the internal data structure (Array). * * @author Jon van Noort (jo...@we...) * * @param newChild : DOMNode - the Node to be inserted * @param refChildIndex : int - the array index to insert the Node before */ DOMNodeList.prototype._insertBefore = function DOMNodeList__insertBefore(newChild, refChildIndex) { if ((refChildIndex >= 0) && (refChildIndex < this._nodes.length)) { // bounds check // get array containing children prior to refChild var tmpArr = new Array(); tmpArr = this._nodes.slice(0, refChildIndex); if (newChild.nodeType == DOMNode.DOCUMENT_FRAGMENT_NODE) { // node is a DocumentFragment // append the children of DocumentFragment tmpArr = tmpArr.concat(newChild.childNodes._nodes); } else { // append the newChild tmpArr[tmpArr.length] = newChild; } // append the remaining original children (including refChild) this._nodes = tmpArr.concat(this._nodes.slice(refChildIndex)); this.length = this._nodes.length; // update length } }; /** * @method DOMNodeList._replaceChild - replace the specified Node in the NodeList at the specified index * Used by DOMNode.replaceChild(). Note: DOMNode.replaceChild() is responsible for Node Pointer surgery * DOMNodeList._replaceChild() simply modifies the internal data structure (Array). * * @author Jon van Noort (jo...@we...) * * @param newChild : DOMNode - the Node to be inserted * @param refChildIndex : int - the array index to hold the Node */ DOMNodeList.prototype._replaceChild = function DOMNodeList__replaceChild(newChild, refChildIndex) { var ret = null; if ((refChildIndex >= 0) && (refChildIndex < this._nodes.length)) { // bounds check ret = this._nodes[refChildIndex]; // preserve old child for return if (newChild.nodeType == DOMNode.DOCUMENT_FRAGMENT_NODE) { // node is a DocumentFragment // get array containing children prior to refChild var tmpArr = new Array(); tmpArr = this._nodes.slice(0, refChildIndex); // append the children of DocumentFragment tmpArr = tmpArr.concat(newChild.childNodes._nodes); // append the remaining original children (not including refChild) this._nodes = tmpArr.concat(this._nodes.slice(refChildIndex + 1)); } else { // simply replace node in array (links between Nodes are made at higher level) this._nodes[refChildIndex] = newChild; } } return ret; // return replaced node }; /** * @method DOMNodeList._removeChild - remove the specified Node in the NodeList at the specified index * Used by DOMNode.removeChild(). Note: DOMNode.removeChild() is responsible for Node Pointer surgery * DOMNodeList._replaceChild() simply modifies the internal data structure (Array). * * @author Jon van Noort (jo...@we...) * * @param refChildIndex : int - the array index holding the Node to be removed */ DOMNodeList.prototype._removeChild = function DOMNodeList__removeChild(refChildIndex) { var ret = null; if (refChildIndex > -1) { // found it! ret = this._nodes[refChildIndex]; // return removed node // rebuild array without removed child var tmpArr = new Array(); tmpArr = this._nodes.slice(0, refChildIndex); this._nodes = tmpArr.concat(this._nodes.slice(refChildIndex +1)); this.length = this._nodes.length; // update length } return ret; // return removed node }; /** * @method DOMNodeList._appendChild - append the specified Node to the NodeList * Used by DOMNode.appendChild(). Note: DOMNode.appendChild() is responsible for Node Pointer surgery * DOMNodeList._appendChild() simply modifies the internal data structure (Array). * * @author Jon van Noort (jo...@we...) * * @param newChild : DOMNode - the Node to be inserted */ DOMNodeList.prototype._appendChild = function DOMNodeList__appendChild(newChild) { if (newChild.nodeType == DOMNode.DOCUMENT_FRAGMENT_NODE) { // node is a DocumentFragment // append the children of DocumentFragment this._nodes = this._nodes.concat(newChild.childNodes._nodes); } else { // simply add node to array (links between Nodes are made at higher level) this._nodes[this._nodes.length] = newChild; } this.length = this._nodes.length; // update length }; /** * @method DOMNodeList._cloneNodes - Returns a NodeList containing clones of the Nodes in this NodeList * * @author Jon van Noort (jo...@we...) * * @param deep : boolean - If true, recursively clone the subtree under each of the nodes; * if false, clone only the nodes themselves (and their attributes, if it is an Element). * @param parentNode : DOMNode - the new parent of the cloned NodeList * * @return : DOMNodeList - NodeList containing clones of the Nodes in this NodeList */ DOMNodeList.prototype._cloneNodes = function DOMNodeList__cloneNodes(deep, parentNode) { var cloneNodeList = new DOMNodeList(this.ownerDocument, parentNode); // create list containing clones of each child for (var i=0; i < this._nodes.length; i++) { cloneNodeList._appendChild(this._nodes[i].cloneNode(deep)); } return cloneNodeList; }; /** * @method DOMNodeList.toString - Serialize this NodeList into an XML string * * @author Jon van Noort (jo...@we...) and David Joham (dj...@ya...) * * @return : string */ DOMNodeList.prototype.toString = function DOMNodeList_toString() { var ret = ""; // create string containing the concatenation of the string values of each child for (var i=0; i < this.length; i++) { ret += this._nodes[i].toString(); } return ret; }; /** * @class DOMNamedNodeMap - used to represent collections of nodes that can be accessed by name * typically a set of Element attributes * * @extends DOMNodeList - note W3C spec says that this is not the case, * but we need an item() method identicle to DOMNodeList's, so why not? * * @author Jon van Noort (jo...@we...) * * @param ownerDocument : DOMDocument - the ownerDocument * @param parentNode : DOMNode - the node that the DOMNamedNodeMap is attached to (or null) */ DOMNamedNodeMap = function(ownerDocument, parentNode) { this._class = addClass(this._class, "DOMNamedNodeMap"); this.DOMNodeList = DOMNodeList; this.DOMNodeList(ownerDocument, parentNode); }; DOMNamedNodeMap.prototype = new DOMNodeList; /** * @method DOMNamedNodeMap.getNamedItem - Retrieves a node specified by name * * @author Jon van Noort (jo...@we...) * * @param name : string - Name of a node to retrieve * * @return : DOMNode */ DOMNamedNodeMap.prototype.getNamedItem = function DOMNamedNodeMap_getNamedItem(name) { var ret = null; // test that Named Node exists var itemIndex = this._findNamedItemIndex(name); if (itemIndex > -1) { // found it! ret = this._nodes[itemIndex]; // return NamedNode } return ret; // if node is not found, default value null is returned }; /** * @method DOMNamedNodeMap.setNamedItem - Adds a node using its nodeName attribute * * @author Jon van Noort (jo...@we...) * * @param arg : DOMNode - A node to store in a named node map. * The node will later be accessible using the value of the nodeName attribute of the node. * If a node with that name is already present in the map, it is replaced by the new one. * * @throws : DOMException - WRONG_DOCUMENT_ERR: Raised if arg was created from a different document than the one that created this map. * @throws : DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this NamedNodeMap is readonly. * @throws : DOMException - INUSE_ATTRIBUTE_ERR: Raised if arg is an Attr that is already an attribute of another Element object. * The DOM user must explicitly clone Attr nodes to re-use them in other elements. * * @return : DOMNode - If the new Node replaces an existing node with the same name the previously existing Node is returned, * otherwise null is returned */ DOMNamedNodeMap.prototype.setNamedItem = function DOMNamedNodeMap_setNamedItem(arg) { // test for exceptions if (this.ownerDocument.implementation.errorChecking) { // throw Exception if arg was not created by this Document if (this.ownerDocument != arg.ownerDocument) { throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR)); } // throw Exception if DOMNamedNodeMap is readonly if (this._readonly || (this.parentNode && this.parentNode._readonly)) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } // throw Exception if arg is already an attribute of another Element object if (arg.ownerElement && (arg.ownerElement != this.parentNode)) { throw(new DOMException(DOMException.INUSE_ATTRIBUTE_ERR)); } } // get item index var itemIndex = this._findNamedItemIndex(arg.name); var ret = null; if (itemIndex > -1) { // found it! ret = this._nodes[itemIndex]; // use existing Attribute // throw Exception if DOMAttr is readonly if (this.ownerDocument.implementation.errorChecking && ret._readonly) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } else { this._nodes[itemIndex] = arg; // over-write existing NamedNode } } else { this._nodes[this.length] = arg; // add new NamedNode } this.length = this._nodes.length; // update length arg.ownerElement = this.parentNode; // update ownerElement return ret; // return old node or null }; /** * @method DOMNamedNodeMap.removeNamedItem - Removes a node specified by name. * * @author Jon van Noort (jo...@we...) * * @param name : string - The name of a node to remove * * @throws : DOMException - NOT_FOUND_ERR: Raised if there is no node named name in this map. * @throws : DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this NamedNodeMap is readonly. * * @return : DOMNode - The node removed from the map or null if no node with such a name exists. */ DOMNamedNodeMap.prototype.removeNamedItem = function DOMNamedNodeMap_removeNamedItem(name) { var ret = null; // test for exceptions // throw Exception if DOMNamedNodeMap is readonly if (this.ownerDocument.implementation.errorChecking && (this._readonly || (this.parentNode && this.parentNode._readonly))) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } // get item index var itemIndex = this._findNamedItemIndex(name); // throw Exception if there is no node named name in this map if (this.ownerDocument.implementation.errorChecking && (itemIndex < 0)) { throw(new DOMException(DOMException.NOT_FOUND_ERR)); } // get Node var oldNode = this._nodes[itemIndex]; // throw Exception if Node is readonly if (this.ownerDocument.implementation.errorChecking && oldNode._readonly) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } // return removed node return this._removeChild(itemIndex); }; /** * @method DOMNamedNodeMap.getNamedItemNS - Retrieves a node specified by name * * @author Jon van Noort (jo...@we...) * * @param namespaceURI : string - the namespace URI of the required node * @param localName : string - the local name of the required node * * @return : DOMNode */ DOMNamedNodeMap.prototype.getNamedItemNS = function DOMNamedNodeMap_getNamedItemNS(namespaceURI, localName) { var ret = null; // test that Named Node exists var itemIndex = this._findNamedItemNSIndex(namespaceURI, localName); if (itemIndex > -1) { // found it! ret = this._nodes[itemIndex]; // return NamedNode } return ret; // if node is not found, default value null is returned }; /** * @method DOMNamedNodeMap.setNamedItemNS - Adds a node using * * @author Jon van Noort (jo...@we...) * * @param arg : string - A node to store in a named node map. * The node will later be accessible using the value of the nodeName attribute of the node. * If a node with that name is already present in the map, it is replaced by the new one. * * @throws : DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this NamedNodeMap is readonly. * @throws : DOMException - WRONG_DOCUMENT_ERR: Raised if arg was created from a different document than the one that created this map. * @throws : DOMException - INUSE_ATTRIBUTE_ERR: Raised if arg is an Attr that is already an attribute of another Element object. * The DOM user must explicitly clone Attr nodes to re-use them in other elements. * * @return : DOMNode - If the new Node replaces an existing node with the same name the previously existing Node is returned, * otherwise null is returned */ DOMNamedNodeMap.prototype.setNamedItemNS = function DOMNamedNodeMap_setNamedItemNS(arg) { // test for exceptions if (this.ownerDocument.implementation.errorChecking) { // throw Exception if DOMNamedNodeMap is readonly if (this._readonly || (this.parentNode && this.parentNode._readonly)) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } // throw Exception if arg was not created by this Document if (this.ownerDocument != arg.ownerDocument) { throw(new DOMException(DOMException.WRONG_DOCUMENT_ERR)); } // throw Exception if arg is already an attribute of another Element object if (arg.ownerElement && (arg.ownerElement != this.parentNode)) { throw(new DOMException(DOMException.INUSE_ATTRIBUTE_ERR)); } } // get item index var itemIndex = this._findNamedItemNSIndex(arg.namespaceURI, arg.localName); var ret = null; if (itemIndex > -1) { // found it! ret = this._nodes[itemIndex]; // use existing Attribute // throw Exception if DOMAttr is readonly if (this.ownerDocument.implementation.errorChecking && ret._readonly) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } else { this._nodes[itemIndex] = arg; // over-write existing NamedNode } } else { this._nodes[this.length] = arg; // add new NamedNode } this.length = this._nodes.length; // update length arg.ownerElement = this.parentNode; return ret; // return old node or null }; /** * @method DOMNamedNodeMap.removeNamedItemNS - Removes a node specified by name. * * @author Jon van Noort (jo...@we...) * * @param namespaceURI : string - the namespace URI of the required node * @param localName : string - the local name of the required node * * @throws : DOMException - NOT_FOUND_ERR: Raised if there is no node with the specified namespaceURI and localName in this map. * @throws : DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this NamedNodeMap is readonly. * * @return : DOMNode - The node removed from the map or null if no node with such a name exists. */ DOMNamedNodeMap.prototype.removeNamedItemNS = function DOMNamedNodeMap_removeNamedItemNS(namespaceURI, localName) { var ret = null; // test for exceptions // throw Exception if DOMNamedNodeMap is readonly if (this.ownerDocument.implementation.errorChecking && (this._readonly || (this.parentNode && this.parentNode._readonly))) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } // get item index var itemIndex = this._findNamedItemNSIndex(namespaceURI, localName); // throw Exception if there is no matching node in this map if (this.ownerDocument.implementation.errorChecking && (itemIndex < 0)) { throw(new DOMException(DOMException.NOT_FOUND_ERR)); } // get Node var oldNode = this._nodes[itemIndex]; // throw Exception if Node is readonly if (this.ownerDocument.implementation.errorChecking && oldNode._readonly) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } return this._removeChild(itemIndex); // return removed node }; /** * @method DOMNamedNodeMap._findNamedItemIndex - find the item index of the node with the specified name * * @author Jon van Noort (jo...@we...) * * @param name : string - the name of the required node * * @return : int */ DOMNamedNodeMap.prototype._findNamedItemIndex = function DOMNamedNodeMap__findNamedItemIndex(name) { var ret = -1; // loop through all nodes for (var i=0; i<this._nodes.length; i++) { // compare name to each node's nodeName if (this._nodes[i].name == name) { // found it! ret = i; break; } } return ret; // if node is not found, default value -1 is returned }; /** * @method DOMNamedNodeMap._findNamedItemNSIndex - find the item index of the node with the specified namespaceURI and localName * * @author Jon van Noort (jo...@we...) * * @param namespaceURI : string - the namespace URI of the required node * @param localName : string - the local name of the required node * * @return : int */ DOMNamedNodeMap.prototype._findNamedItemNSIndex = function DOMNamedNodeMap__findNamedItemNSIndex(namespaceURI, localName) { var ret = -1; // test that localName is not null if (localName) { // loop through all nodes for (var i=0; i<this._nodes.length; i++) { // compare name to each node's namespaceURI and localName if ((this._nodes[i].namespaceURI == namespaceURI) && (this._nodes[i].localName == localName)) { ret = i; // found it! break; } } } return ret; // if node is not found, default value -1 is returned }; /** * @method DOMNamedNodeMap._hasAttribute - Returns true if specified node exists * * @author Jon van Noort (jo...@we...) * * @param name : string - the name of the required node * * @return : boolean */ DOMNamedNodeMap.prototype._hasAttribute = function DOMNamedNodeMap__hasAttribute(name) { var ret = false; // test that Named Node exists var itemIndex = this._findNamedItemIndex(name); if (itemIndex > -1) { // found it! ret = true; // return true } return ret; // if node is not found, default value false is returned } /** * @method DOMNamedNodeMap._hasAttributeNS - Returns true if specified node exists * * @author Jon van Noort (jo...@we...) * * @param namespaceURI : string - the namespace URI of the required node * @param localName : string - the local name of the required node * * @return : boolean */ DOMNamedNodeMap.prototype._hasAttributeNS = function DOMNamedNodeMap__hasAttributeNS(namespaceURI, localName) { var ret = false; // test that Named Node exists var itemIndex = this._findNamedItemNSIndex(namespaceURI, localName); if (itemIndex > -1) { // found it! ret = true; // return true } return ret; // if node is not found, default value false is returned } /** * @method DOMNamedNodeMap._cloneNodes - Returns a NamedNodeMap containing clones of the Nodes in this NamedNodeMap * * @author Jon van Noort (jo...@we...) * * @param parentNode : DOMNode - the new parent of the cloned NodeList * * @return : DOMNamedNodeMap - NamedNodeMap containing clones of the Nodes in this DOMNamedNodeMap */ DOMNamedNodeMap.prototype._cloneNodes = function DOMNamedNodeMap__cloneNodes(parentNode) { var cloneNamedNodeMap = new DOMNamedNodeMap(this.ownerDocument, parentNode); // create list containing clones of all children for (var i=0; i < this._nodes.length; i++) { cloneNamedNodeMap._appendChild(this._nodes[i].cloneNode(false)); } return cloneNamedNodeMap; }; /** * @method DOMNamedNodeMap.toString - Serialize this NodeMap into an XML string * * @author Jon van Noort (jo...@we...) and David Joham (dj...@ya...) * * @return : string */ DOMNamedNodeMap.prototype.toString = function DOMNamedNodeMap_toString() { var ret = ""; // create string containing concatenation of all (but last) Attribute string values (separated by spaces) for (var i=0; i < this.length -1; i++) { ret += this._nodes[i].toString() +" "; } // add last Attribute to string (without trailing space) if (this.length > 0) { ret += this._nodes[this.length -1].toString(); } return ret; }; /** * @class DOMNamespaceNodeMap - used to represent collections of namespace nodes that can be accessed by name * typically a set of Element attributes * * @extends DOMNamedNodeMap * * @author Jon van Noort (jo...@we...) * * @param ownerDocument : DOMDocument - the ownerDocument * @param parentNode : DOMNode - the node that the DOMNamespaceNodeMap is attached to (or null) */ DOMNamespaceNodeMap = function(ownerDocument, parentNode) { this._class = addClass(this._class, "DOMNamespaceNodeMap"); this.DOMNamedNodeMap = DOMNamedNodeMap; this.DOMNamedNodeMap(ownerDocument, parentNode); }; DOMNamespaceNodeMap.prototype = new DOMNamedNodeMap; /** * @method DOMNamespaceNodeMap._findNamedItemIndex - find the item index of the node with the specified localName * * @author Jon van Noort (jo...@we...) * * @param localName : string - the localName of the required node * * @return : int */ DOMNamespaceNodeMap.prototype._findNamedItemIndex = function DOMNamespaceNodeMap__findNamedItemIndex(localName) { var ret = -1; // loop through all nodes for (var i=0; i<this._nodes.length; i++) { // compare name to each node's nodeName if (this._nodes[i].localName == localName) { // found it! ret = i; break; } } return ret; // if node is not found, default value -1 is returned }; /** * @method DOMNamespaceNodeMap._cloneNodes - Returns a NamespaceNodeMap containing clones of the Nodes in this NamespaceNodeMap * * @author Jon van Noort (jo...@we...) * * @param parentNode : DOMNode - the new parent of the cloned NodeList * * @return : DOMNamespaceNodeMap - NamespaceNodeMap containing clones of the Nodes in this NamespaceNodeMap */ DOMNamespaceNodeMap.prototype._cloneNodes = function DOMNamespaceNodeMap__cloneNodes(parentNode) { var cloneNamespaceNodeMap = new DOMNamespaceNodeMap(this.ownerDocument, parentNode); // create list containing clones of all children for (var i=0; i < this._nodes.length; i++) { cloneNamespaceNodeMap._appendChild(this._nodes[i].cloneNode(false)); } return cloneNamespaceNodeMap; }; /** * @method DOMNamespaceNodeMap.toString - Serialize this NamespaceNodeMap into an XML string * * @author Jon van Noort (jo...@we...) and David Joham (dj...@ya...) * * @return : string */ DOMNamespaceNodeMap.prototype.toString = function DOMNamespaceNodeMap_toString() { var ret = ""; // identify namespaces declared local to this Element (ie, not inherited) for (var ind = 0; ind < this._nodes.length; ind++) { // if namespace declaration does not exist in the containing node's, parentNode's namespaces var ns = null; try { var ns = this.parentNode.parentNode._namespaces.getNamedItem(this._nodes[ind].localNa me); } catch (e) { //breaking to prevent default namespace being inserted into return value break; } if (!(ns && (""+ ns.nodeValue == ""+ this._nodes[ind].nodeValue))) { // display the namespace declaration ret += this._nodes[ind].toString() +" "; } } return ret; }; /** * @class DOMNode - The Node interface is the primary datatype for the entire Document Object Model. * It represents a single node in the document tree. * * @author Jon van Noort (jo...@we...) * * @param ownerDocument : DOMDocument - The Document object associated with this node. */ DOMNode = function(ownerDocument) { this._class = addClass(this._class, "DOMNode"); if (ownerDocument) { this._id = ownerDocument._genId(); // generate unique internal id } this.namespaceURI = ""; // The namespace URI of this node (Level 2) this.prefix = ""; // The namespace prefix of this node (Level 2) this.localName = ""; // The localName of this node (Level 2) this.nodeName = ""; // The name of this node this.nodeValue = ""; // The value of this node this.nodeType = 0; // A code representing the type of the underlying object // The parent of this node. All nodes, except Document, DocumentFragment, and Attr may have a parent. // However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is null this.parentNode = null; // A NodeList that contains all children of this node. If there are no children, this is a NodeList containing no nodes. // The content of the returned NodeList is "live" in the sense that, for instance, changes to the children of the node object // that it was created from are immediately reflected in the nodes returned by the NodeList accessors; // it is not a static snapshot of the content of the node. This is true for every NodeList, including the ones returned by the getElementsByTagName method. this.childNodes = new DOMNodeList(ownerDocument, this); this.firstChild = null; // The first child of this node. If there is no such node, this is null this.lastChild = null; // The last child of this node. If there is no such node, this is null. this.previousSibling = null; // The node immediately preceding this node. If there is no such node, this is null. this.nextSibling = null; // The node immediately following this node. If there is no such node, this is null. this.attributes = new DOMNamedNodeMap(ownerDocument, this); // A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise. this.ownerDocument = ownerDocument; // The Document object associated with this node this._namespaces = new DOMNamespaceNodeMap(ownerDocument, this); // The namespaces in scope for this node this._readonly = false; }; // nodeType constants DOMNode.ELEMENT_NODE = 1; DOMNode.ATTRIBUTE_NODE = 2; DOMNode.TEXT_NODE = 3; DOMNode.CDATA_SECTION_NODE = 4; DOMNode.ENTITY_REFERENCE_NODE = 5; DOMNode.ENTITY_NODE = 6; DOMNode.PROCESSING_INSTRUCTION_NODE = 7; DOMNode.COMMENT_NODE = 8; DOMNode.DOCUMENT_NODE = 9; DOMNode.DOCUMENT_TYPE_NODE = 10; DOMNode.DOCUMENT_FRAGMENT_NODE = 11; DOMNode.NOTATION_NODE = 12; DOMNode.NAMESPACE_NODE = 13; /** * @method DOMNode.hasAttributes * * @author Jon van Noort (jo...@we...) & David Joham (dj...@ya...) * * @return : boolean */ DOMNode.prototype.hasAttributes = function DOMNode_hasAttributes() { if (this.attributes.length == 0) { return false; } else { return true; } }; /** * @method DOMNode.getNodeName - Java style gettor for .nodeName * * @author Jon van Noort (jo...@we...) * * @return : string */ DOMNode.prototype.getNodeName = function DOMNode_getNodeName() { return this.nodeName; }; /** * @method DOMNode.getNodeValue - Java style gettor for .NodeValue * * @author Jon van Noort (jo...@we...) * * @return : string */ DOMNode.prototype.getNodeValue = function DOMNode_getNodeValue() { return this.nodeValue; }; /** * @method DOMNode.setNodeValue - Java style settor for .NodeValue * * @author Jon van Noort (jo...@we...) * * @param nodeValue : string - unique internal id */ DOMNode.prototype.setNodeValue = function DOMNode_setNodeValue(nodeValue) { // throw Exception if DOMNode is readonly if (this.ownerDocument.implementation.errorChecking && this._readonly) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } this.nodeValue = nodeValue; }; /** * @method DOMNode.getNodeType - Java style gettor for .nodeType * * @author Jon van Noort (jo...@we...) * * @return : int */ DOMNode.prototype.getNodeType = function DOMNode_getNodeType() { return this.nodeType; }; /** * @method DOMNode.getParentNode - Java style gettor for .parentNode * * @author Jon van Noort (jo...@we...) * * @return : DOMNode */ DOMNode.prototype.getParentNode = function DOMNode_getParentNode() { return this.parentNode; }; /** * @method DOMNode.getChildNodes - Java style gettor for .childNodes * * @author Jon van Noort (jo...@we...) * * @return : DOMNodeList */ DOMNode.prototype.getChildNodes = function DOMNode_getChildNodes() { return this.childNodes; }; /** * @method DOMNode.getFirstChild - Java style gettor for .firstChild * * @author Jon van Noort (jo...@we...) * * @return : DOMNode */ DOMNode.prototype.getFirstChild = function DOMNode_getFirstChild() { return this.firstChild; }; /** * @method DOMNode.getLastChild - Java style gettor for .lastChild * * @author Jon van Noort (jo...@we...) * * @return : DOMNode */ DOMNode.prototype.getLastChild = function DOMNode_getLastChild() { return this.lastChild; }; /** * @method DOMNode.getPreviousSibling - Java style gettor for .previousSibling * * @author Jon van Noort (jo...@we...) * * @return : DOMNode */ DOMNode.prototype.getPreviousSibling = function DOMNode_getPreviousSibling() { return this.previousSibling; }; /** * @method DOMNode.getNextSibling - Java style gettor for .nextSibling * * @author Jon van Noort (jo...@we...) * * @return : DOMNode */ DOMNode.prototype.getNextSibling = function DOMNode_getNextSibling() { return this.nextSibling; }; /** * @method DOMNode.getAttributes - Java style gettor for .attributes * * @author Jon van Noort (jo...@we...) * * @return : DOMNamedNodeList */ DOMNode.prototype.getAttributes = function DOMNode_getAttributes() { return this.attributes; }; /** * @method DOMNode.getOwnerDocument - Java style gettor for .ownerDocument * * @author Jon van Noort (jo...@we...) * * @return : DOMDocument */ DOMNode.prototype.getOwnerDocument = function DOMNode_getOwnerDocument() { return this.ownerDocument; }; /** * @method DOMNode.getNamespaceURI - Java style gettor for .namespaceURI * * @author Jon van Noort (jo...@we...) * * @return : String */ DOMNode.prototype.getNamespaceURI = function DOMNode_getNamespaceURI() { return this.namespaceURI; }; /** * @method DOMNode.getPrefix - Java style gettor for .prefix * * @author Jon van Noort (jo...@we...) * * @return : String */ DOMNode.prototype.getPrefix = function DOMNode_getPrefix() { return this.prefix; }; /** * @method DOMNode.setPrefix - Java style settor for .prefix * * @author Jon van Noort (jo...@we...) * * @param prefix : String * * @throws : DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this Node is readonly. * @throws : DOMException - INVALID_CHARACTER_ERR: Raised if the string contains an illegal character * @throws : DOMException - NAMESPACE_ERR: Raised if the Namespace is invalid * */ DOMNode.prototype.setPrefix = function DOMNode_setPrefix(prefix) { // test for exceptions if (this.ownerDocument.implementation.errorChecking) { // throw Exception if DOMNode is readonly if (this._readonly) { throw(new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR)); } // throw Exception if the prefix string contains an illegal character if (!this.ownerDocument.implementation._isValidName(prefix)) { thr... [truncated message content] |