//Introduced in DOM Level 2 AttrNSImpl::AttrNSImpl(DocumentImpl *ownerDoc, const DOMString &fNamespaceURI, const DOMString &qualifiedName) : AttrImpl(ownerDoc, qualifiedName) { DOMString xmlns = NodeImpl::getXmlnsString(); DOMString xmlnsURI = NodeImpl::getXmlnsURIString(); this->name = qualifiedName.clone(); int index = DocumentImpl::indexofQualifiedName(qualifiedName); DOMString prefix; if (index < 0) throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null); bool xmlnsAlone = false; //true if attribute name is "xmlns" if (index == 0) { //qualifiedName contains no ':' if (this->name.equals(xmlns)) { if (!fNamespaceURI.equals(xmlnsURI)) throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null); xmlnsAlone = true; } prefix = null; this -> localName = this -> name; } else { //0 < index < this->name.length()-1 prefix = this->name.substringData(0, index); this -> localName = this->name.substringData(index+1, this->name.length()-index-1); } const DOMString& URI = xmlnsAlone ? xmlnsURI : mapPrefix(prefix, fNamespaceURI, DOM_Node::ATTRIBUTE_NODE); this -> namespaceURI = URI == null ? DOMString(null) : URI.clone(); };
//Introduced in DOM Level 2 ElementNSImpl::ElementNSImpl(DocumentImpl *ownerDoc, const DOMString &fNamespaceURI, const DOMString &qualifiedName) : ElementImpl(ownerDoc, qualifiedName) { this->name = qualifiedName.clone(); int index = DocumentImpl::indexofQualifiedName(qualifiedName); DOMString prefix; if (index < 0) throw DOM_DOMException(DOM_DOMException::NAMESPACE_ERR, null); if (index == 0) { //qualifiedName contains no ':' prefix = null; this -> localName = this -> name; } else { //0 < index < this->name.length()-1 prefix = this->name.substringData(0, index); this -> localName = this->name.substringData(index+1, this->name.length()-index-1); } const DOMString& URI = mapPrefix(prefix, fNamespaceURI, DOM_Node::ELEMENT_NODE); this -> namespaceURI = URI == null ? DOMString(null) : URI.clone(); } /* SPEC_CPU: removed extra ';' for C++98 standards compliance -- yag */