virtual void attributeEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *value, const XMLCh *typeURI, const XMLCh *typeName) { assert(node_ && node_->getNodeType() == DOMNode::ELEMENT_NODE); DOMNamedNodeMap *attrs = node_->getAttributes(); DOMAttr *at = (DOMAttr*)attrs->getNamedItemNS(uri, localname); // Add the attribute if(!at) { at = node_->getOwnerDocument()->createAttributeNS(uri, localname); if(prefix && *prefix) at->setPrefix(prefix); attrs->setNamedItemNS(at); } // Copy the schema normalized value at->setNodeValue(value); // Copy the attribute's type const XMLCh *oldTypeURI, *oldTypeName; XercesNodeImpl::typeUriAndName(at, oldTypeURI, oldTypeName); if(!XPath2Utils::equals(oldTypeName, typeName) || !XPath2Utils::equals(oldTypeURI, typeURI)) { XercesSequenceBuilder::setAttributeTypeInfo(at, typeURI, typeName); } }
void XercesUpdateFactory::setTypes(DOMNode *node, const DOMNode *from) { if(node->getNodeType() == DOMNode::ELEMENT_NODE) { const XMLCh *turi, *tname; XercesNodeImpl::typeUriAndName(from, turi, tname); XercesSequenceBuilder::setElementTypeInfo((DOMElement *)node, turi, tname); DOMNamedNodeMap *attrs = node->getAttributes(); DOMNamedNodeMap *attrsfrom = from->getAttributes(); for(unsigned int i = 0; i < attrs->getLength(); ++i) { DOMNode *a = attrs->item(i); DOMNode *afrom = attrsfrom->getNamedItemNS(a->getNamespaceURI(), Axis::getLocalName(a)); if(afrom) setTypes(a, afrom); } DOMNode *child = node->getFirstChild(); DOMNode *cfrom = from->getFirstChild(); while(child) { if(child->getNodeType() == DOMNode::ELEMENT_NODE) setTypes(child, cfrom); child = child->getNextSibling(); cfrom = cfrom->getNextSibling(); } } else if(node->getNodeType() == DOMNode::ATTRIBUTE_NODE) { const XMLCh *turi, *tname; XercesNodeImpl::typeUriAndName(from, turi, tname); XercesSequenceBuilder::setAttributeTypeInfo((DOMAttr *)node, turi, tname); } }