当前位置: 首页>>代码示例>>C++>>正文


C++ DOMElement::setAttributeNode方法代码示例

本文整理汇总了C++中DOMElement::setAttributeNode方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMElement::setAttributeNode方法的具体用法?C++ DOMElement::setAttributeNode怎么用?C++ DOMElement::setAttributeNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DOMElement的用法示例。


在下文中一共展示了DOMElement::setAttributeNode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: toXML

DOMElement* EppCommandInfoLaunchRegistration::toXML( DOMDocument& doc, const DOMString& tag )
{
	DOMElement* elm;
	DOMElement* body = EppUtil::createElementNS(doc, "launch", (tag.isNull()) ? "info" : tag, false, "-1.0");

	DOMAttr* attr = doc.createAttribute(XS("includeMark"));
	attr->setValue( ( this->_includeMark ) ? XS("true") : XS("false") );
	body->setAttributeNode(attr);

	if( this->_phase.phase().length() > 0 )
	{
		DOMElement* elm = this->_phase.toXML(doc, "phase");
		body->appendChild(elm);
	}
	if( this->_appId.isNotNull() )
	{
		if( this->_appId.length() > 0 )
		{
			elm = doc.createElement(XS("applicationID"));
			elm->appendChild(doc.createTextNode(this->_appId));
			body->appendChild(elm);
		}
	}
	return body;
}
开发者ID:neustar,项目名称:registrar_toolkit,代码行数:25,代码来源:EppCommandInfoLaunchRegistration.cpp

示例2: toXML

DOMElement* EppCommandCreateLaunchRegistration::toXML( DOMDocument& doc, const DOMString& tag )
{
    DOMElement* elm;
    DOMElement* body = EppUtil::createElementNS(doc, "launch", (tag.isNull()) ? "create" : tag, false, "-1.0");

    if( this->_type.length() > 0 )
    {
        DOMAttr* attr = doc.createAttribute(XS("type"));
        attr->setValue( this->_type);
        body->setAttributeNode(attr);
    }

    if ( this->_phase.phase().length() > 0 )
    {
        DOMElement* elm = this->_phase.toXML(doc, "phase");
        body->appendChild(elm);
    }

    if( (_signedMark.hasSMD()) )
    {   /*RAII*/
        DOMElement* elm = this->_signedMark.toXML(doc, "signedMark");
        body->appendChild(elm);
    }
    if( (_encSignedMark.hasSMD()) )
    {   /*RAII*/
        DOMElement* elm = this->_encSignedMark.toXML(doc, "encodedSignedMark");
        body->appendChild(elm);
    }
    if( this->_noticeID.length() > 0  )
    {
        elm = doc.createElement(XS("noticeID"));
        elm->appendChild(doc.createTextNode(this->_noticeID));
        body->appendChild(elm);
    }
    if( this->_notAfter.length() > 0  )
    {
        elm = doc.createElement(XS("notAfter"));
        elm->appendChild(doc.createTextNode(this->_notAfter));
        body->appendChild(elm);
    }
    if( this->_acceptedDate.length() > 0  )
    {
        elm = doc.createElement(XS("acceptedDate"));
        elm->appendChild(doc.createTextNode(this->_acceptedDate));
        body->appendChild(elm);
    }

    return body;
}
开发者ID:neustar,项目名称:registrar_toolkit,代码行数:49,代码来源:EppCommandCreateLaunchRegistration.cpp

示例3: toXML

DOMElement* EppLaunchPhase::toXML(DOMDocument &doc, const DOMString &tag)
{
    //DOMElement* elm;
    DOMElement* body = doc.createElement(tag);
    if( this->_sub_phase.length() > 0 )
    {
        DOMAttr* attr = doc.createAttribute(XS("name"));
        attr->setValue( this->_sub_phase );
        body->setAttributeNode(attr);
    }
    if( this->_phase.length() > 0 )
    {
        body->appendChild(doc.createTextNode(this->_phase));
    }
    return body;
}
开发者ID:neustar,项目名称:registrar_toolkit,代码行数:16,代码来源:EppLaunchPhase.cpp

示例4: applyReplaceAttribute

void XercesUpdateFactory::applyReplaceAttribute(const PendingUpdate &update, DynamicContext *context)
{
  const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla);
  DOMAttr *domnode = (DOMAttr*)nodeImpl->getDOMNode();
  Node::Ptr parentNode = nodeImpl->dmParent(context);
  DOMElement *element = domnode->getOwnerElement();
  DOMDocument *doc = element->getOwnerDocument();

  bool untyped = parentNode->dmNodeKind() == Node::element_string &&
    XPath2Utils::equals(parentNode->getTypeName(), DocumentCache::g_szUntyped) &&
    XPath2Utils::equals(parentNode->getTypeURI(), SchemaSymbols::fgURI_SCHEMAFORSCHEMA);

  Result children = update.getValue();
  Item::Ptr item;
  while((item = children->next(context)).notNull()) {
    const XercesNodeImpl *childImpl = (const XercesNodeImpl*)item->getInterface(Item::gXQilla);
    DOMNode *newChild = importNodeFix(doc, const_cast<DOMNode*>(childImpl->getDOMNode()), /*deep*/true);

    // 1. Error checks:
    //    a. If the QNames of any two attribute nodes in $replacement have implied namespace bindings that conflict with
    //       each other, a dynamic error is raised [err:XUDY0024].
    //    b. If the QName of any attribute node in $replacement has an implied namespace binding that conflicts with a
    //       namespace binding in the "namespaces" property of parent($target), a dynamic error is raised [err:XUDY0024].
    // Checks performed by UpdateFactory

    // 2b. If the type-name property of parent($target) is xs:untyped, then upd:setToUntyped() is invoked
    //     on each element node in $replacement.
    if(!untyped) setTypes(newChild, childImpl->getDOMNode());

    // 2a. For each node in $replacement, the parent property is set to parent($target).
    // 4a. If $target is an attribute node, the attributes property of parent($target) is modified by removing $target
    //     and adding the nodes in $replacement (if any).
    // 4b. If $target is an attribute node, the namespaces property of parent($target) is modified to include namespace
    //     bindings for any attribute namespace prefixes in $replacement that did not already have bindings.
    element->setAttributeNode((DOMAttr*)newChild);
  }

  // 3a. $target is marked for deletion.
  forDeletion_.insert(domnode);

  // 4d. upd:removeType(parent($target)) is invoked.
  removeType(element);

  // Use parentNode, since the attr replace could have removed the original attr
  addToPutSet(parentNode, &update, context);
}
开发者ID:xubingyue,项目名称:xqilla,代码行数:46,代码来源:XercesUpdateFactory.cpp

示例5: toXML

/* NOTE: need to keep _type field in consideration as attribute type/entitlement depends on it.*/
DOMElement* EppMarkHolder::toXML(DOMDocument &doc, const DOMString &tag)
{
	DOMString attr_name = "type";
	DOMElement* elm;
	DOMElement* body = doc.createElement(tag);

	if( this->_type == EPPMARK_HOLDER )
	{
		attr_name = "entitlement";
	}
	DOMAttr* attr = doc.createAttribute(attr_name);
	attr->setValue( this->_addParam );
	body->setAttributeNode(attr);

	if( this->_name.length() > 0 )
	{
		elm = doc.createElement(XS("name"));
		elm->appendChild(doc.createTextNode(this->_name));
		body->appendChild(elm);
	}
	if( this->_org.length() > 0 )
	{
		elm = doc.createElement(XS("org"));
		elm->appendChild(doc.createTextNode(this->_org));
		body->appendChild(elm);
	}
	body->appendChild(this->_addr.toXML(doc, "addr"));

	if( this->_voice.getNumber().length() > 0 )
	{
		elm = this->_voice.toXML(doc, "voice");
		body->appendChild(elm);
	}
	if( this->_fax.getNumber().length() > 0 )
	{
		elm = this->_fax.toXML(doc, "fax");
		body->appendChild(elm);
	}
	if( this->_email.length() > 0 )
	{
		elm = doc.createElement(XS("email"));
		elm->appendChild(doc.createTextNode(this->_email));
		body->appendChild(elm);
	}
	return body;
}
开发者ID:neustar,项目名称:registrar_toolkit,代码行数:47,代码来源:EppMarkHolder.cpp

示例6: rename

DOMNode* DOMAttrImpl::rename(const XMLCh* namespaceURI, const XMLCh* name)
{
    DOMElement* el = getOwnerElement();
    DOMDocumentImpl* doc = (DOMDocumentImpl*)fParent.fOwnerDocument;

    if (el)
        el->removeAttributeNode(this);

    if (!namespaceURI || !*namespaceURI) {
        fName = doc->getPooledString(name);

        if (el)
            el->setAttributeNode(this);

        // and fire user data NODE_RENAMED event
        castToNodeImpl(this)->callUserDataHandlers(DOMUserDataHandler::NODE_RENAMED, this, this);

        return this;
    }
    else {

        // create a new AttrNS
        DOMAttr* newAttr = doc->createAttributeNS(namespaceURI, name);

        // transfer the userData
        doc->transferUserData(castToNodeImpl(this), castToNodeImpl(newAttr));

        // move children to new node
        DOMNode* child = getFirstChild();
        while (child) {
            removeChild(child);
            newAttr->appendChild(child);
            child = getFirstChild();
        }

        // reattach attr to element
        if (el)
            el->setAttributeNodeNS(newAttr);

        // and fire user data NODE_RENAMED event
        castToNodeImpl(newAttr)->callUserDataHandlers(DOMUserDataHandler::NODE_RENAMED, this, newAttr);

        return newAttr;
    }
}
开发者ID:AmesianX,项目名称:Sigil,代码行数:45,代码来源:DOMAttrImpl.cpp

示例7: applyInsertAttributes

void XercesUpdateFactory::applyInsertAttributes(const PendingUpdate &update, DynamicContext *context)
{
  const XercesNodeImpl *nodeImpl = (const XercesNodeImpl*)update.getTarget()->getInterface(Item::gXQilla);
  DOMElement *element = (DOMElement*)nodeImpl->getDOMNode();
  DOMDocument *doc = const_cast<DOMDocument*>(XPath2Utils::getOwnerDoc(element));

  bool untyped = nodeImpl->dmNodeKind() == Node::element_string &&
    XPath2Utils::equals(nodeImpl->getTypeName(), DocumentCache::g_szUntyped) &&
    XPath2Utils::equals(nodeImpl->getTypeURI(), SchemaSymbols::fgURI_SCHEMAFORSCHEMA);

  Result children = update.getValue();
  Item::Ptr item;
  while((item = children->next(context)).notNull()) {
    const XercesNodeImpl *childImpl = (const XercesNodeImpl*)item->getInterface(Item::gXQilla);
    DOMNode *newChild = importNodeFix(doc, const_cast<DOMNode*>(childImpl->getDOMNode()), /*deep*/true);

    // 1. Error checks:
    //    a. If the QNames of any two attribute nodes in $content have implied namespace bindings that conflict with each other,
    //       a dynamic error is raised [err:XUDY0024].
    //    b. If the QName of any attribute node in $content has an implied namespace binding that conflicts with a namespace
    //       binding in the "namespaces" property of $target, a dynamic error is raised [err:XUDY0024].
    // Checks performed by UpdateFactory

    // If the type-name property of $target is xs:untyped, then upd:setToUntyped($A) is invoked.
    if(!untyped) setTypes(newChild, childImpl->getDOMNode());

    // The parent property of $A is set to $target.
    // attributes: Modified to include the nodes in $content.
    element->setAttributeNode((DOMAttr*)newChild);

  }

  // upd:removeType($target) is invoked.
  removeType(element);

  addToPutSet(update.getTarget(), &update, context);
}
开发者ID:xubingyue,项目名称:xqilla,代码行数:37,代码来源:XercesUpdateFactory.cpp

示例8: toXMLCommon

DOMElement* EppCommand::toXMLCommon( DOMDocument& doc, const DOMString command, DOMElement* element, EppEntity * object, const DOMString tag, ValueVectorOf<DOMAttr*> * attrList )
{
	DOMElement* elm = null;
	DOMElement* epp = EppUtil::createElementNS(doc, "epp", NULLXS);
	DOMElement* body = doc.createElement(XS("command"));
	epp->appendChild(body);

	//if( creds != null )
	//{
	//	body->appendChild(creds->toXML(doc, "creds"));
	//}

	if( this->getEntityType() == EppEntity::TYPE_EppCommandLogin )
	{
		elm = element;
	}
	else
	{
		elm = doc.createElement(command);
	}
	if( elm != null )
	{
	if( attrList != null )
	{
		for( unsigned int i = 0; i < attrList->size(); i++ )
		{
			DOMAttr* obj = attrList->elementAt(i);
			elm->setAttributeNode(obj);
		}
	}
	if( object != null )
	{
		elm->appendChild(object->toXML(doc, tag));
	}
		else if( element != null )
	{
		if( this->getEntityType() != EppEntity::TYPE_EppCommandLogin )
		{
				elm->appendChild(element);
		}
	}
	body->appendChild(elm);
	}

	if( extension != null )
	{
		elm = null;
		for( unsigned int i = 0; i < extension->size(); i++ )
		{
			EppEntity * obj = extension->elementAt(i);
			DOMElement* ext;
			if( obj == null )
			{
				continue;
			}
			if( obj->getEntityType() == EppEntity::TYPE_EppExtensionUnspec )
			{
				EppUnspec * unspec = (EppUnspec *) obj;
				ext = unspec->toXML(doc, "extension");
			}
			else if( obj->instanceOf(EppEntity::TYPE_EppExtension) == true )
			{
				EppExtension * extobj = (EppExtension *) obj;
				ext = extobj->toXML(doc, NULLXS);
			}
			else
			{
				ext = obj->toXML(doc, "extension");
			}
			if( ext != null )
			{
				if( elm == null )
				{
					elm = doc.createElement(XS("extension"));
					body->appendChild(elm);
				}
				elm->appendChild(ext);
			}
		}
	}

	if( clTRID.isNotNull() )
	{
		elm = doc.createElement(XS("clTRID"));
		elm->appendChild(doc.createTextNode(clTRID));
		body->appendChild(elm);
	}

	return epp;
}
开发者ID:neustar,项目名称:registrar_toolkit,代码行数:90,代码来源:EppCommand.cpp

示例9: main

/**
 * Main routine that utilizes Xercesc module to create a DOM object in memory 
 * and prints out the resultant DOM structure 
 * @param argC    number of command line args 
 * @param argV    name of command line args 
 * @return        0 if no errors occurred 
 */
int main(int argC, char*argv[]) {
    // Initialize the XML4C2 system.
    try {
        XMLPlatformUtils::Initialize();
} catch (const XMLException& toCatch) {
    char *pMsg = XMLString::transcode(toCatch.getMessage());
    XERCES_STD_QUALIFIER cerr << "Error during Xerces-c Initialization.\n" << "  Exception message:" << pMsg;
    XMLString::release(&pMsg);
    return 1;
}

    // Watch for special case help request
    int errorCode = 0;
    if (argC > 1) {
        XERCES_STD_QUALIFIER
        cout << "\nUsage:\n"
                "    CreateDOMDocument\n\n"
                "This program creates a new DOM document from scratch in memory.\n"
                "It then prints the count of elements in the tree.\n" << XERCES_STD_QUALIFIER
                endl;
        errorCode = 1;
    }
    if (errorCode) {
        XMLPlatformUtils::Terminate();
        return errorCode;
    }


    DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(X("Core"));

    if (impl != NULL) {
        try {
            // create a DomDocument instance
            DOMDocument* doc = impl->createDocument(
                    0, // root element namespace URI.
                    X("TheHood"), // root element name
                    0); // document type object (DTD).

            // create root attribute nodes
            DOMAttr* woop_atr = doc->createAttribute(X("WOOP"));
            woop_atr->setValue(X("DANG"));
            DOMAttr* fiyah_atr = doc->createAttribute(X("FIYAH"));
            fiyah_atr->setValue(X("hot"));
            DOMAttr* hungry_atr = doc->createAttribute(X("hungry"));
            hungry_atr->setValue(X("starving"));

            // create root element
            DOMElement* rootElem = doc->getDocumentElement();
            // set root attrs
            rootElem->setAttributeNode(woop_atr);
            rootElem->setAttributeNode(fiyah_atr);
            rootElem->setAttributeNode(hungry_atr);

            //create root child elements
            DOMElement* gangElem = doc->createElement(X("gang"));
            rootElem->appendChild(gangElem);
            DOMText* gangDataVal = doc->createTextNode(X("YoungThugz"));
            gangElem->appendChild(gangDataVal);
            gangElem->setAttribute(X("hardness"), X("rock"));

            //create gang attr nodes
            DOMAttr* members_atr = doc->createAttribute(X("members"));
            members_atr->setValue(X("500"));
            DOMAttr* color_atr = doc->createAttribute(X("color"));
            color_atr->setValue(X("magenta"));
            // set gang attr
            gangElem->setAttributeNode(members_atr);
            gangElem->setAttributeNode(color_atr);
            // create gang elem children
            DOMElement* piruElem = doc->createElement(X("piru"));
            piruElem->setNodeValue(X("w"));
            DOMElement* cripElem = doc->createElement(X("crip"));
            cripElem->setNodeValue(X("t"));
            DOMElement* trgElem = doc->createElement(X("trg"));
            trgElem->setNodeValue(X("o"));
            // append gang elem children
            gangElem->appendChild(piruElem);
            gangElem->appendChild(cripElem);
            gangElem->appendChild(trgElem);

            DOMElement* turfElem = doc->createElement(X("turf"));
            rootElem->appendChild(turfElem);
            turfElem->setAttribute(X("idea"), X("great"));
            DOMText* turfDataVal = doc->createTextNode(X("West Side Projects"));
            turfElem->appendChild(turfDataVal);

            DOMElement* cliqueElem = doc->createElement(X("clique"));
            rootElem->appendChild(cliqueElem);
            DOMText* cliqueDataVal = doc->createTextNode(X("Balla$"));
            cliqueElem->appendChild(cliqueDataVal);
            cliqueElem->setAttribute(X("Comradery"), X("tight"));

            DOMElement* sideElem = doc->createElement(X("side"));
//.........这里部分代码省略.........
开发者ID:kidculli,项目名称:XMLParser,代码行数:101,代码来源:main.cpp


注:本文中的DOMElement::setAttributeNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。