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


C++ DOMAttr::getName方法代码示例

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


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

示例1: getAttributeByName

std::string getAttributeByName (DOMNode* node, std::string attrName) {
	cdebug << "getAttr " << attrName << std::endl;
	assert (node->getNodeType () == DOMNode::ELEMENT_NODE);
	
	std::string value = "";
	
	if (node->hasAttributes()) {
		DOMNamedNodeMap *pAttributes = node->getAttributes ();
		
		for (unsigned int i = 0; i < pAttributes->getLength (); i++) {
			DOMAttr* pAttributeNode = (DOMAttr*) pAttributes->item(i);
			char* name = XMLString::transcode(pAttributeNode->getName());
			if (name == attrName) {
				char* tmpValue = XMLString::transcode(pAttributeNode->getValue());
				value = tmpValue;
				XMLString::release(&tmpValue);
			}
			XMLString::release(&name);
		}
	} else {
		cdebug << "Error in file to parse" << std::endl;
		throw ("Error in file to parse attributes");
	}
	cdebug << value << std::endl;
	return value;
} /* std::string getAttributeByName (DOMNode* node, std::string attrName) */
开发者ID:BackupTheBerlios,项目名称:moneybook-svn,代码行数:26,代码来源:libmoneybook.cpp

示例2:

void SYSTEM::CConfigItem::RemoveAllAttributes()
{
	if(((DOMElement*)itemElement)->hasAttributes())
	{
		DOMNamedNodeMap *pAttributes = ((DOMElement*)itemElement)->getAttributes();
		XMLSize_t count = pAttributes->getLength();
		DOMAttr* pNode = NULL;
		for (XMLSize_t i = 0 ; i < count ; ++i)
		{
			pNode = (DOMAttr*)pAttributes->item(0);

			if( m_curValue != NULL )
				XMLString::release(&m_curValue);
			if(!pNode)		//属性名称不存在
				m_curValue = NULL;
			else
				m_curValue = XMLString::transcode(pNode->getName());/*DOMAttr **/

			((DOMElement*)itemElement)->removeAttribute(pNode->getName());
		}
	}
}
开发者ID:lozpeng,项目名称:applesales,代码行数:22,代码来源:ConfigItem.cpp

示例3: AddElement

XMLNode *JobXML::deepCopyElement( XMLNode **copy, const XMLNode *original )
{
   // add the element to the copy
   char *nodeName = XMLString::transcode( original->getNodeName() );
   XMLNode *newElement = AddElement( (*copy), nodeName );
   XMLString::release( &nodeName );

   // add its attributes
   if ( original->hasAttributes() )
   {
      DOMNamedNodeMap *attributes = original->getAttributes();
      for( unsigned int i=0; i<attributes->getLength(); i++ )
      {
         DOMAttr *attr = (DOMAttr*)attributes->item( i );
         char *key = XMLString::transcode( attr->getName() );
         char *val = XMLString::transcode( attr->getValue() );
         SetAttribute( newElement, key, val );
         XMLString::release( &key );
         XMLString::release( &val );
      }
   }

   // recursively copy all child elements
   int childElementCount=0;
   XMLNode *itr = original->getFirstChild();
   for ( ; itr != NULL; itr = itr->getNextSibling() )
   {      
      if ( itr->getNodeType() == XMLNode::ELEMENT_NODE )
      {
         deepCopyElement( &newElement, itr );
         childElementCount++;
      }
   }

   // if no child elements, copy this element's text content and we are done
   if ( childElementCount == 0 )
   {
      char *content = XMLString::transcode( original->getTextContent() );
      SetContent( newElement, content );
      XMLString::release( &content );
   }

   return newElement;
}
开发者ID:VRAC-WATCH,项目名称:deltajug,代码行数:44,代码来源:job_xml.cpp

示例4:

// ---------------------------------------------------------------------------
// utility func to extract a DOMNodes Base attr value if present
// ---------------------------------------------------------------------------
static const XMLCh *
getBaseAttrValue(DOMNode *node){
    if (node->getNodeType() == DOMNode::ELEMENT_NODE){
        DOMElement *elem = (DOMElement *)node;
        if(elem->hasAttributes()) {
            /* get all the attributes of the node */
            DOMNamedNodeMap *pAttributes = elem->getAttributes();
            XMLSize_t nSize = pAttributes->getLength();
            for(XMLSize_t i=0;i<nSize;++i) {
                DOMAttr *pAttributeNode = (DOMAttr*) pAttributes->item(i);
                /* get attribute name */
                if (XMLString::equals(pAttributeNode->getName(), XIncludeUtils::fgXIBaseAttrName)){
                    /*if (namespace == XMLUni::fgXMLString){

                    }*/
                    return pAttributeNode->getValue();
                }
            }
        }
    }
    return NULL;
}
开发者ID:kanbang,项目名称:Colt,代码行数:25,代码来源:XIncludeUtils.cpp

示例5: construct

void XmlTag::construct(XmlTag * parent, DOMNode * n, bool logging)
{
    this->parent = parent;
    this->name = "unknown";
    if (parent == NULL)
    {
        if (logging)
        {
            pLogEngine l (LogEngine::create (LOG_DEVELOPER, "XmlTag"));
            this->log = l;
        }
    }
    else
    {
        if (logging) this->log = parent->log;
    }

    if (n == NULL)
    {
        if (logging) log->__format(LOG_ERROR, "Empty tag (%s)!", getFullName().c_str());
        return;
    }
    if (n->getNodeType() != DOMNode::ELEMENT_NODE)
    {
        if (logging) log->__format(LOG_ERROR, "This (%s) is not a tag!", getFullName().c_str());
    }
    assignXmlString (name, n->getNodeName());

    //fill tag attributes map
    if (!n->hasAttributes())
    {
        if (logging) log->__format(LOG_WARNING, "No attributes in this tag (%s)!", getFullName().c_str() );
    }
    else
    {
        std::string attributeName = "";
        std::string attributeData = "";
        DOMNamedNodeMap *attList = n->getAttributes ();
        int size = attList->getLength ();
        for (int i = 0; i < size; ++i)
        {
            DOMAttr *attNode = (DOMAttr *) attList->item (i);
            assignXmlString (attributeName, attNode->getName ());
            assignXmlString (attributeData, attNode->getValue ());
            if ( (attributeName != "") && (attributeData != "") )
            {
                attributes[attributeName] = attributeData;
                attributesRead[attributeName] = false;
            }
        }
    }
    //fill child tags map
    if (n->hasChildNodes())
    {
        std::string childTagName;
        for (n = n->getFirstChild (); n != 0; n = n->getNextSibling ())
        {
            if (n) if (n->getNodeType() == DOMNode::ELEMENT_NODE)
                {
                    assignXmlString (childTagName, n->getNodeName());
                    //XmlTag * tmpTag = new XmlTag(this, n, logging);
                    XmlTag * tmpTag = new XmlTag(this, n);
                    tags.push_back(tmpTag);
                }
        }
    }
}
开发者ID:stenyak,项目名称:motorsport,代码行数:67,代码来源:xmlTag.cpp

示例6: if

// ---------------------------------------------------------------------------
//  This method assumes that currentNode is an xinclude element and parses
//   it accordingly, acting on what it finds.
// ---------------------------------------------------------------------------
bool
XIncludeUtils::doDOMNodeXInclude(DOMNode *xincludeNode, DOMDocument *parsedDocument, XMLEntityHandler* entityResolver){
    bool modifiedNode = false;
    /* the relevant attributes to look for */
    const XMLCh *href = NULL;
    const XMLCh *parse = NULL;
    const XMLCh *xpointer = NULL;
    const XMLCh *encoding = NULL;
    const XMLCh *accept = NULL;
    const XMLCh *acceptlanguage = NULL;
    DOMNode *includeParent = xincludeNode->getParentNode();


    if(xincludeNode->hasAttributes()) {
        /* get all the attributes of the node */
        DOMNamedNodeMap *pAttributes = xincludeNode->getAttributes();
        XMLSize_t nSize = pAttributes->getLength();
        for(XMLSize_t i=0;i<nSize;++i) {
            DOMAttr *pAttributeNode = (DOMAttr*) pAttributes->item(i);
            const XMLCh *attrName = pAttributeNode->getName();
            /* check each attribute against the potential useful names */
            if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeHREFAttrName)){
                href = pAttributeNode->getValue();
            } else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeParseAttrName)){
                parse = pAttributeNode->getValue();
            } else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeXPointerAttrName)){
                xpointer = pAttributeNode->getValue();
            } else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeEncodingAttrName)){
                encoding = pAttributeNode->getValue();
            } else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeAcceptAttrName)){
                accept = pAttributeNode->getValue();
            } else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeAcceptLanguageAttrName)){
                acceptlanguage = pAttributeNode->getValue();
            } else {
                /* if any other attribute is in the xi namespace, it's an error */
                const XMLCh *attrNamespaceURI = pAttributeNode->getNamespaceURI();
                if (attrNamespaceURI && XMLString::equals(attrNamespaceURI, XIncludeUtils::fgXIIIncludeNamespaceURI)){
                } else {
                    /* ignore - any other attribute is allowed according to spec,
                       and must be ignored */
                }
            }
        }
    }
    // 3.1 xi:include Element
    // The children property of the xi:include element may include a single xi:fallback element;
    // the appearance of more than one xi:fallback element, an xi:include element,
    // or any other element from the XInclude namespace is a fatal error.
    DOMNode *child;
    DOMElement *fallback = NULL;
    for (child = xincludeNode->getFirstChild(); child != 0; child=child->getNextSibling()){
        if(child->getNodeType()!=DOMNode::ELEMENT_NODE)
            continue;
        if ( isXIFallbackDOMNode(child) ){
            if (fallback != NULL){
                /* fatal error - there are more than one fallback children */
                XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeMultipleFallbackElems,
                    parsedDocument->getDocumentURI(), parsedDocument->getDocumentURI());
                return false;
            }
            fallback = (DOMElement*)child;
        }
        else if(isXIIncludeDOMNode(child) || XMLString::equals(child->getNamespaceURI(), XIncludeUtils::fgXIIIncludeNamespaceURI)) {
            /* fatal error - an xi element different from xi:fallback is a child of xi:include */
            XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeDisallowedChild,
                child->getNodeName(), parsedDocument->getDocumentURI());
            return false;
        }
    }

    if (href == NULL){
        /* this is an unrecoverable error until we have xpointer support -
           if there is an xpointer, the current document is assumed
           however, there is no xpointer support yet */
        XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeNoHref,
            NULL, parsedDocument->getDocumentURI());
        return false;
    }

    /* set up the accept and accept-language values */
    if (accept != NULL){

    }

    if (parse == NULL){
        /* use the default, as specified */
        parse = XIncludeUtils::fgXIIncludeParseAttrXMLValue;
    }

    if (xpointer != NULL){
        /* not supported yet */
        /* Note that finding an xpointer attr along with parse="text" is a Fatal Error
         *  - http://www.w3.org/TR/xinclude/#include-location */
        XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeXPointerNotSupported,
            NULL, href);
        return false;
//.........这里部分代码省略.........
开发者ID:kanbang,项目名称:Colt,代码行数:101,代码来源:XIncludeUtils.cpp

示例7: dequeue


//.........这里部分代码省略.........
					DEBUG( "Current position in chunk is "  );
					stringstream errorMessage;
					errorMessage << "Batch file [" << m_CrtStorageId << "] contains no usable data";
					TRACE( errorMessage.str() );
					throw runtime_error( errorMessage.str() );	
				}
				else
				{
					//repositioning in the file to the end of the last match 
					DEBUG( "Current position in chunk is " << m_CrtIndex );
					m_CrtStorage.seekg( m_CrtIndex - m_ChunkSize, ios::cur );
					// reset the chunk
					if ( m_Buffer != NULL )
					{
						delete[] m_Buffer;
						m_Buffer = NULL;
					}
					//try with next chunk or reset the chunk and verify if it is bad formatted storage
					dequeue();
					
				}
			}
			// realloc buffer
		}
		else // template matched
		{
			m_NextItem.setSequence( m_CrtSequence++ );
			m_NextItem.setBatchId( m_CrtStorageId );
			m_NextItem.setMessageId( Collaboration::GenerateGuid() );

			if ( m_Parser.getTemplateFile().length() == 0 )
			{	
				// quick workaround xmling
				string base64Value = Base64::encode( m_Buffer, m_BufferLength );  
				rootElem->setAttribute( unicodeForm( "base64" ), unicodeForm( base64Value ) );

				m_NextItem.setPayload( XmlUtil::SerializeToString( outputData ) );

				// reset the chunk
				if ( m_Buffer != NULL )
				{
					delete[] m_Buffer;
					m_Buffer = NULL;
				}
			}
			else
			{
				m_CrtIndex += m_Parser.getMatchEnd();
			
				DEBUG( "End point for match is : " << m_CrtIndex );
			
				// from root( Message ) -> child ( template format ) -> child ( selection friendly name ) -> attribute ( data )
				if( rootElem == NULL )
					throw logic_error( "Root empty" );
				if( rootElem->getFirstChild() == NULL )
					throw logic_error( "Template child empty" );
				if( rootElem->getFirstChild()->getFirstChild() == NULL )
				{
					TRACE( XmlUtil::SerializeToString( rootElem ) );
					throw logic_error( "Template child2 empty" );
				}

				DOMNamedNodeMap *attributes = rootElem->getFirstChild()->getFirstChild()->getAttributes();
				if ( attributes != NULL )
				{
					DEBUG( "Number of attributes for selection : " << attributes->getLength() );
				
					for ( unsigned int i=0; i<attributes->getLength(); i++ )
					{
						DOMAttr *attribute = dynamic_cast< DOMAttr * >( attributes->item( i ) );
						if ( attribute == NULL )
							continue;

						string attributeName = localForm( attribute->getName() );
						string attributeValue = localForm( attribute->getValue() );
					
						string attributeValueToLog = ( attributeValue.length() > 100 ) ? attributeValue.substr( 0, 100 ) + string( "..." ) : attributeValue;
						DEBUG( "Attribute [" << attributeName << "] = [" << attributeValueToLog << "]" );
						m_NextItem.setPayload( attributeValue );
					}
				}
			}
		}
		if ( outputData != NULL )
		{
			outputData->release();
			outputData = NULL;
		}
	}
	catch( ... )
	{
		if ( outputData != NULL )
		{
			outputData->release();
			outputData = NULL;
		}
		throw;
	}
	return item;
}
开发者ID:FinTP,项目名称:fintp_base,代码行数:101,代码来源:BatchFlatfileStorage.cpp

示例8: parseDOMElement

void XMLData::parseDOMElement(DOMElement* element) {
	string name(XMLString::transcode(element->getTagName()));

	DOMNamedNodeMap* map = element->getAttributes();
	for (XMLSize_t i = 0; i < map->getLength(); i++) {
		DOMAttr* attr = static_cast<DOMAttr*>(map->item(i));
		string attr_name(XMLString::transcode(attr->getName()));
		string attr_value(XMLString::transcode(attr->getValue()));
		int value;
		try {
			value = stoi(attr_value);
			if(name == "hairiness") {
				if(attr_name == "typesMax") {
					hairTypeLength = nbBitsMin(value-1);
				}
			}
			else if(name == "limbs") {
				if(attr_name == "nbMax") {
					limbNbLength = nbBitsMin(value);
				}
				else if(attr_name == "sizeMax") {
					limbSizeLength = nbBitsMin(value);
				}
				else if(attr_name == "typesMax") {
					limbTypeLength = nbBitsMin(value-1);
				}
			}
			else if(name == "ears") {
				if(attr_name == "nbMax") {
					earNbLength = nbBitsMin(value);
				}
			}
			else if(name == "eyes") {
				if(attr_name == "nbMax") {
					eyeNbLength = nbBitsMin(value);
				}
			}
			else if(name == "nostrils") {
				if(attr_name == "nbMax") {
					nostrilNbLength = nbBitsMin(value);
				}
			}
			else if(name == "width") {
				if(attr_name == "typesMax") {
					mouthWidthTypeLength = nbBitsMin(value-1);
				}
			}
			else if(name == "teeth") {
				if(attr_name == "nbMax") {
					teethNbLength = nbBitsMin(value);
				}
				else if(attr_name == "typesMax") {
					teethTypeLength = nbBitsMin(value-1);
				}
			}
		}
		catch(invalid_argument& e) {
			if(name == "type") {
				string parentName(XMLString::transcode(static_cast<DOMElement*>(element->getParentNode())->getTagName()));
				if(parentName == "hairiness") {
					hairTypes.push_back(attr_value);
				}
				else if(parentName == "limbs") {
					limbTypes.push_back(attr_value);
				}
				else if(parentName == "width") {
					mouthWidthTypes.push_back(attr_value);
				}
				else if(parentName == "teeth") {
					teethTypes.push_back(attr_value);
				}
			}
		}
		/*
		cout << "\t" << attr_name << ": "<< attr_value << endl;
		*/
	}
}
开发者ID:Agurato,项目名称:Graine_DNA,代码行数:78,代码来源:XMLData.cpp

示例9: generateData

void XmlSchemaGenerator::generateData ( const wxString &elementName,
		size_t nIndent /*= 0*/)
{
	ElmtData &data = mElements[elementName];
	std::set<const DOMElement *>::iterator elmtItr;

	data.name = elementName;

	//Content
	std::map<wxString, ChildData> &childMap = data.children;
	std::map<wxString, ChildData>::iterator itr;
	std::set<wxString> previous;
	elmtItr = data.nodes.begin();
	for ( ; elmtItr != data.nodes.end(); ++elmtItr )
	{
		previous.clear();

		std::map<wxString, size_t> countMap;
		DOMElement *child = ( **elmtItr ).getFirstElementChild();
		for ( ; child != NULL; child = child->getNextElementSibling() )
		{
			wxString name = WrapXerces::toString ( child->getTagName() );
			childMap[name].prevSiblings.insert ( previous.begin(), previous.end() );
			childMap[name].prevSiblings.erase ( name ); // Don't depend on oneself
			previous.insert ( name );
			countMap[name] += 1;
		}
		std::map<wxString, size_t>::iterator countItr = countMap.begin();
		for ( ; countItr != countMap.end(); ++countItr )
		{
			if ( childMap[countItr->first].maxOccurs < countItr->second )
				childMap[countItr->first].maxOccurs = countItr->second;
		}
		if ( childMap.size() == countMap.size() )
			continue;
		for ( itr = childMap.begin(); itr != childMap.end(); ++itr )
		{
			if ( countMap.find ( itr->first ) != countMap.end() )
				continue;
			itr->second.minOccurs = 0;
		}
	}
	// Attribute
	std::map<wxString, const XMLCh *> &attrMap = data.attrMap;
	std::set<wxString> &optAttrs = data.optAttrs;
	std::map<wxString, const XMLCh *>::iterator attrItr;
	elmtItr = data.nodes.begin();
	for ( ; elmtItr != data.nodes.end(); ++elmtItr )
	{
		if ( ! ( **elmtItr ).hasAttributes() )
			continue;

		wxString name;
		DOMAttr *attr;
		DOMNamedNodeMap *attrs = ( **elmtItr ).getAttributes();
		size_t i = attrs->getLength();
		while ( i-- > 0 )
		{
			attr = ( DOMAttr* ) attrs->item ( i );
			name = WrapXerces::toString ( attr->getName() );
			if ( attr->getPrefix() != NULL )
			{
				wxLogDebug ( _T("Ignore: %s"), name.c_str() );
				continue;
			}
			if ( attr->getSpecified() )
				attrMap[name]; // Initialize attribute map
			else
				attrMap[name] = attr->getValue();
		}
		if ( attrMap.size() == optAttrs.size() )
			continue;
		for ( attrItr = attrMap.begin(); attrItr != attrMap.end(); ++attrItr )
		{
			if ( attrs->getNamedItem ( ( const XMLCh * )
					WrapXerces::toString ( attrItr->first ).GetData() ) == NULL )
			{
				optAttrs.insert ( attrItr->first );
			}
		}
	}

	// Deal with sequence
	wxLogDebug ( _T("%s:"), elementName.c_str() );
	data.useSequence = getSequence ( data.sequence, childMap );

	// Now we have the data of the element
	if ( mGrammarType == Grammar::DTDGrammarType )
	{
		generateDTD ( data, nIndent );
		mSchema << data.schema;
	}
	else if ( !mInlineSimpleType )
	{ // Or wait until all data are available
		generateSchema ( data, nIndent );
		mSchema << data.schema;
	}
}
开发者ID:Distrotech,项目名称:xmlcopyeditor,代码行数:98,代码来源:xmlschemagenerator.cpp


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