Пример #1
0
  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);
    }
  }
Пример #2
0
void DOMElementImpl::setAttribute(const XMLCh *nam, const XMLCh *val)
{
    if (fNode.isReadOnly())
        throw DOMException(
        DOMException::NO_MODIFICATION_ALLOWED_ERR, 0);

    DOMAttr* newAttr = getAttributeNode(nam);
    if (!newAttr)
    {
        newAttr = this->fNode.getOwnerDocument()->createAttribute(nam);
        fAttributes->setNamedItem(newAttr);
    }

    newAttr->setNodeValue(val);
}
Пример #3
0
void DOMElementImpl::setAttributeNS(const XMLCh *fNamespaceURI,
    const XMLCh *qualifiedName, const XMLCh *fValue)
{
    if (fNode.isReadOnly())
        throw DOMException(
        DOMException::NO_MODIFICATION_ALLOWED_ERR, 0);

    DOMAttr* newAttr = getAttributeNodeNS(fNamespaceURI, qualifiedName);

    if (!newAttr)
    {
        newAttr = this->fNode.getOwnerDocument()->createAttributeNS(fNamespaceURI, qualifiedName);
        fAttributes->setNamedItemNS(newAttr);
    }

    newAttr->setNodeValue(fValue);
}
Пример #4
0
void DeltaApplyEngine::Attribute_Insert( XID_t nodeXID, const XMLCh* attr, const XMLCh* value ) {
	vddprintf(("        insert attr at xid=%d\n",(int)nodeXID));
	DOMNode* node = xiddoc->getXidMap().getNodeWithXID( nodeXID );
	if (node==NULL) THROW_AWAY(("node with XID=%d not found",(int)nodeXID));
	DOMAttr* attrNode = xiddoc->createAttribute( attr );
	attrNode->setNodeValue( value );
	DOMNamedNodeMap *attrs = node->getAttributes();
	if (attrs == NULL) {
		if (node->getNodeType() != DOMNode::ELEMENT_NODE) {
			THROW_AWAY(("Attempted to insert an attribute on a non-element node. Perhaps xidmap was corrupted?"));
		} else {
			THROW_AWAY(("Unexpected error encountered: getAttributes() returned NULL for element"));
		}
	} else {
		attrs->setNamedItem( attrNode );
	}
	
}
Пример #5
0
void DOMElementImpl::setAttributeNS(const XMLCh *fNamespaceURI,
    const XMLCh *qualifiedName, const XMLCh *fValue)
{
    if (fNode.isReadOnly())
        throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, GetDOMNodeMemoryManager);

    int index = DOMDocumentImpl::indexofQualifiedName(qualifiedName);
    if (index < 0)
        throw DOMException(DOMException::NAMESPACE_ERR, 0, GetDOMNodeMemoryManager);

    DOMAttr* newAttr = getAttributeNodeNS(fNamespaceURI, qualifiedName+index);
    if (!newAttr)
    {
        newAttr = fParent.fOwnerDocument->createAttributeNS(fNamespaceURI, qualifiedName);
        fAttributes->setNamedItemNS(newAttr);
    }

    newAttr->setNodeValue(fValue);
}