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


C++ DOMNamedNodeMap::getLength方法代码示例

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


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

示例1: DOMtoXMLElement

void DOMtoXMLElement(DOMNode* dom, XMLElement& xml)
{
  xml.setName(StrX(dom->getNodeName()));
  unsigned int i;
  string text;
  DOMNodeList* children = dom->getChildNodes();
  for (i=0;children && i<children->getLength();i++) {
    DOMNode* child = children->item(i);
    switch (child->getNodeType()) {
    case DOMNode::TEXT_NODE:
      text+=StrX(child->getNodeValue());
      break;
    case DOMNode::ELEMENT_NODE:
      {
	XMLElement childElement;
	DOMtoXMLElement(child, childElement);
	xml.addChild(childElement);
      }
      break;
    default:
      continue;
    }
  }
  xml.setText(text);
  DOMNamedNodeMap* attrs = dom->getAttributes();
  if (attrs == 0)
    return;
  for (i=0;i<attrs->getLength();i++) {
    DOMNode* attr = attrs->item(i);
    xml.setAttribute(StrX(attr->getNodeName()), StrX(attr->getNodeValue()));
  }
}
开发者ID:arjunroy,项目名称:modelnet-core,代码行数:32,代码来源:xml.cpp

示例2: 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

示例3: getAttributes

// ----------------------------------------------------------------------------
//	Base Attributes Builder
// ----------------------------------------------------------------------------
void AttributesBuilder::getAttributes()
{
	if ( node_->hasAttributes() ) {
		DOMNamedNodeMap* theAttributes = node_->getAttributes();
		int numAttributes = theAttributes->getLength();
	
		for (int n=0; n < numAttributes; ++n) {
			DOMNode* attrib = theAttributes->item(n);

			const XMLCh* xmlch_Name = attrib->getNodeName();
			char* attrName = XMLString::transcode(xmlch_Name);

			const XMLCh* xmlch_Value = attrib->getNodeValue();
			char* attrValue = XMLString::transcode(xmlch_Value);
		
			try {
				//attrib_->update(pname.get(), pval.get());
				attrib_->update(attrName, attrValue);
			} catch (std::runtime_error &ex) {
				std::cerr << ex.what() << std::endl
						<< builderType_ << __FUNCTION__ << "(): "
						<< "In space \"" << attrib_->getValAsStr("name")
						<< "\", unrecognized attribute \"" << attrName << "=" << attrValue
						<< "\". Ignoring it." << std::endl;
			};

			XMLString::release( &attrName );
			XMLString::release( &attrValue );
		}
		
	}
}
开发者ID:yamokosk,项目名称:sceneml,代码行数:35,代码来源:xml_attributes.cpp

示例4: setTypes

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);
  }
}
开发者ID:xubingyue,项目名称:xqilla,代码行数:30,代码来源:XercesUpdateFactory.cpp

示例5: convertToNode

//=============================================================================
// METHOD: SPELLxmlConfigReaderXC::convertToNode
//=============================================================================
SPELLxmlNode* SPELLxmlConfigReaderXC::convertToNode( DOMElement* element )
{
    // Create an abstract node with this name
    SPELLxmlNode* node = new SPELLxmlNode( XMLString::transcode(element->getNodeName()) );

    // Get any possible attributes
    DOMNamedNodeMap* attrs = element->getAttributes();
    XMLSize_t numAttrs = attrs->getLength();
    for( XMLSize_t idx = 0; idx < numAttrs; idx++)
    {
        // Get the attribute node
        DOMNode* attrNode = attrs->item(idx);
        // Get name and value
        const XMLCh* aname  = attrNode->getNodeName();
        const XMLCh* avalue = attrNode->getNodeValue();
        // Convert name and value to strings
        std::string name = "<?>";
        if (aname != NULL)
        {
            name = XMLString::transcode(aname);
        }
        std::string value = "<?>";
        if (avalue != NULL)
        {
            value = XMLString::transcode(avalue);
        }
        node->addAttribute( name, value );
    }

    // Get any possible children
    DOMNodeList* children = element->getChildNodes();
    XMLSize_t numChildren = children->getLength();
    for( XMLSize_t idx = 0; idx < numChildren; idx++)
    {
        // Get the children node
        DOMNode* childNode = children->item(idx);
        // Process only ELEMENTs and TEXTs
        if (childNode->getNodeType() && // true is not NULL
                childNode->getNodeType() == DOMNode::ELEMENT_NODE) // is element
        {
            // For elements, recursively add children
            SPELLxmlNode* child = convertToNode( dynamic_cast<xercesc::DOMElement*>(childNode) );
            node->addChild(child);
        }
        else if (childNode->getNodeType() == DOMNode::TEXT_NODE)
        {
            // For text values, add the value. This code will just ignore
            // carriage-return values
            const XMLCh* nvalue = childNode->getNodeValue();
            if (nvalue != NULL)
            {
                std::string thevalue = XMLString::transcode(nvalue);
                SPELLutils::trim(thevalue, " \n\r\t");
                node->setValue( thevalue );
            }
        }
    }

    return node;
}
开发者ID:unnch,项目名称:spell-sat,代码行数:63,代码来源:SPELLxmlConfigReaderXC.C

示例6: verifyUserTimestampElement

void AcsAlarmTestCase::verifyUserTimestampElement(DOMDocument * doc)
{
	// Verify the user-timestamp element
	DOMNodeList * userTimestampNodes = doc->getElementsByTagName(USER_TIMESTAMP_TAG_NAME);
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; no user-properties element found",
		(NULL != userTimestampNodes && userTimestampNodes->getLength() == 1));

	// verify that there are 2 attributes
	DOMNamedNodeMap * attributesMap = userTimestampNodes->item(0)->getAttributes();
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; user-timestamp element does not contain 2 attributes",
		(NULL!= attributesMap && attributesMap->getLength() == 2));

	// check for seconds attribute
	DOMNode * secondsValueNode = attributesMap->getNamedItem(SECONDS_TAG_NAME);
	const XMLCh * secondsValue = secondsValueNode->getNodeValue();
	char *secondsCharValue = XMLString::transcode(secondsValue);
	int secondsIntValue = atoi(secondsCharValue);
	XMLString::release(&secondsCharValue);
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; user-timestamp element, 'seconds' attribute value is not correct",
		(NULL!= secondsValue && secondsIntValue == SECONDS_VALUE));

	// check for microseconds attribute
	DOMNode * microsecondsValueNode = attributesMap->getNamedItem(MICROSECONDS_TAG_NAME);
	const XMLCh * microsecondsValue = microsecondsValueNode->getNodeValue();
	char *microsecondsCharValue = XMLString::transcode(microsecondsValue);
	int microsecondsIntValue = atoi(microsecondsCharValue);
	XMLString::release(&microsecondsCharValue);
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; user-timestamp element, 'microseconds' attribute value is not correct",
		(NULL!= microsecondsValue && microsecondsIntValue == MICROSECONDS_VALUE));

}
开发者ID:flyingfrog81,项目名称:ACS,代码行数:31,代码来源:testXML.cpp

示例7: if

bool
XMLExtServiceHelper::parseExtServicesReq( DOMNode* cur, DOMNode* out,
                                          DOMDocument* reply, 
                                          bool indent,
                                          const HttpHeader& inHeaders )
{
   // Attributes
   DOMNamedNodeMap* attributes = cur->getAttributes();

   // Language of the request.
   LangTypes::language_t lang = LangTypes::english;
   // Semi-optional crc
   MC2String crc;
   
   for( int i = 0, n = attributes->getLength(); i < n; ++i ) {
      DOMNode* attrib = attributes->item( i );
      if ( XMLString::equals( attrib->getNodeName(), "language" ) ) {
         lang = m_xmlParserThread->getStringAsLanguage( 
            XMLUtility::getChildTextStr( *attrib ).c_str() );
      } else if ( XMLString::equals( attrib->getNodeName(), "crc" ) ) {
         crc = XMLUtility::getChildTextStr( *attrib );
      }
   }

   // Make the answer.
   appendExternalSearchDesc( out,
                             reply,
                             cur,
                             crc,
                             lang,
                             1,
                             indent );

   return true;
}
开发者ID:FlavioFalcao,项目名称:Wayfinder-Server,代码行数:35,代码来源:XMLExtServiceHelper.cpp

示例8: if

EppCommandInfoLaunchRegistration* EppCommandInfoLaunchRegistration::fromXML( const DOMNode& root )
{
	EppCommandInfoLaunchRegistration* cmd  = new EppCommandInfoLaunchRegistration();
	if( cmd == null )
	{
		return null;
	}
	DOMNodeList* list      = root.getChildNodes();
	DOMNamedNodeMap* attrs = root.getAttributes();

	for( unsigned int i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node  = list->item(i);
		DOMString name = node->getLocalName();
		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
		if( (name.length() > 7) && name.substringData(0, 7).equals("launch:") )
		{
			name = name.substringData(7, name.length() - 7);
		}
		if( name.equals("phase") )
		{
			EppLaunchPhase *_pptr = EppLaunchPhase::fromXML(*node);
			if( null != _pptr )
			{
				cmd->_phase = *_pptr;
				delete _pptr;
			}
			_pptr = null;
		}
		else if ( name.equals("applicationID") )
		{
			cmd->_appId = EppUtil::getText(*node);
		}
	}
	for( unsigned int i = 0;i<attrs->getLength();i++ )
	{
		DOMNode* attr = attrs->item(i);
		if( XS(attr->getNodeName()).equals("includeMark") )
		{
			DOMString _v = attr->getNodeValue();
			if( _v.length() > 0 )
			{
				if( _v.equals("true") )
				{
					cmd->includeMark(true);
				}
			}
			break;
		}
	}
	return cmd;
}
开发者ID:neustar,项目名称:registrar_toolkit,代码行数:59,代码来源:EppCommandInfoLaunchRegistration.cpp

示例9: verifyFaultStateElement

void AcsAlarmTestCase::verifyFaultStateElement(DOMDocument * doc, bool propertiesAndTimestampPopulated)
{
	// Verify that the fault-state element exists
	DOMNodeList * faultStateNodes = doc->getElementsByTagName(FAULT_STATE_TAG_NAME);
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; no fault-state element found",
		(NULL != faultStateNodes && faultStateNodes->getLength() == 1));

	// verify that there are the expected attributes (family, member, code) on the fault-state element
	DOMNode * faultStateItem = faultStateNodes->item(0);
	if(NULL != faultStateItem)
	{
		// verify that there are 3 attributes in total
		DOMNamedNodeMap * attributesMap = faultStateItem->getAttributes();
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; fault-state does not contain 3 attributes",
			(NULL!= attributesMap && attributesMap->getLength() == 3));

		// check that the fault-state element has a "family" attribute
		DOMNode * familyNode = attributesMap->getNamedItem(FAMILY_TAG_NAME);
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; fault-state does not contain 'family' attribute",
			(NULL!= familyNode));

		// verify that the value of family attribute is correct
		const XMLCh * familyNodeValue = familyNode->getNodeValue();
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; value of fault-state 'family' is not correct",
			(NULL != familyNodeValue && XMLString::equals(familyNodeValue, FAMILY_VALUE_XMLCH)));

		// check that the fault-state element has a "member" attribute
		DOMNode * memberNode = attributesMap->getNamedItem(MEMBER_TAG_NAME);
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; fault-state does not contain 'member' attribute",
			(NULL!= memberNode));

		// verify that the value of member attribute is correct
		const XMLCh * memberNodeValue = memberNode->getNodeValue();
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; value of fault-state 'member' is not correct",
			(NULL != memberNodeValue && XMLString::equals(memberNodeValue, MEMBER_VALUE_XMLCH)));

		// check that the fault-state element has a "code" attribute
		DOMNode * codeNode = attributesMap->getNamedItem(CODE_TAG_NAME);
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; fault-state does not contain 'code' attribute",
			(NULL!= codeNode));

		// verify that the value of code attribute is correct
		const XMLCh * codeNodeValue = codeNode->getNodeValue();
		char *codeNodeCharValue = XMLString::transcode(codeNodeValue);
		int codeNodeValueInt = atoi(codeNodeCharValue);
		XMLString::release(&codeNodeCharValue);
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; value of fault-state 'code' is not correct",
			(NULL != codeNodeValue && codeNodeValueInt == CODE_VALUE));
	}

	verifyDescriptorElement(doc);
	if(propertiesAndTimestampPopulated)
	{
		verifyUserPropertiesElement(doc);
		verifyUserTimestampElement(doc);
	}
}
开发者ID:ACS-Community,项目名称:ACS,代码行数:57,代码来源:testXML.cpp

示例10:

void *PointSet::read(DOMNode *node) {
	unsigned int i; 				// variable to counter
	DOMNodeList *children;			// variable to hold the node children
	
	DOMNamedNodeMap *attributes;	// variable to hold the node attributes

	attributes = node->getAttributes();
	for (i = 0; i < attributes->getLength(); i++) {
		if (!strcmp(XMLString::transcode(attributes->item(i)->getNodeName()) , "DEF")) {
			setLink(XMLString::transcode(attributes->item(i)->getNodeValue()),this);
		}// else
		//if (!strcmp(XMLString::transcode(attributes->item(i)->getNodeName()) , "USE")) {
		//	return(getLink(XMLString::transcode(attributes->item(i)->getNodeValue())));
		//} 
	}

	children = node->getChildNodes();
	if (children != NULL) {
		for (i = 0; i < children->getLength (); i++) {			
			if (!strcmp (XMLString::transcode(children->item(i)->getNodeName()),"Coordinate")) {
				coordinate = Coordinate::get(children->item(i));
				coordinateNumber = coordinate->getNumberOfElements();
			} else
			if (!strcmp (XMLString::transcode(children->item(i)->getNodeName()),"Color")) {
				color = Color::get(children->item(i));
				colorNumber = color->getNumberOfElements();
			} 
		}
	}
	
	#ifdef DEBUG
		float sizes[2];
		float step;
		glGetFloatv(GL_POINT_SIZE_RANGE,sizes);
		glGetFloatv(GL_POINT_SIZE_GRANULARITY,&step);
		cout << "Max and Min point size " << sizes[0] << " , " << sizes[1] << " Granularity " << step << endl;
	#endif
	
	if(colorNumber) {
		if(colorNumber==3) {
			cout << "Three colors selected" << endl;
		} else
		if(colorNumber!=coordinateNumber) {
			cerr << "Color and coordinate not matching" << endl;
		}
	}

		
	#ifdef DEBUG
		cout << "Coordinate Number " << coordinateNumber << endl;
		cout << "Color Number " << colorNumber << endl;
	#endif

	return(NULL);
	
}
开发者ID:lpsoares,项目名称:jinx,代码行数:56,代码来源:x3dRendering.cpp

示例11: domCheckSum

//
// domCheckSum  -  Compute the check sum for a DOM node.
//                 Works recursively - initially called with a document node.
//
void ThreadParser::domCheckSum(const DOMNode *node)
{
    const XMLCh        *s;
    DOMNode          *child;
    DOMNamedNodeMap  *attributes;

    switch (node->getNodeType() )
    {
    case DOMNode::ELEMENT_NODE:
        {
            s = node->getNodeName();   // the element name

            attributes = node->getAttributes();  // Element's attributes
            int numAttributes = attributes->getLength();
            int i;
            for (i=0; i<numAttributes; i++)
                domCheckSum(attributes->item(i));

            addToCheckSum(s);          // Content and Children
            for (child=node->getFirstChild(); child!=0; child=child->getNextSibling())
                domCheckSum(child);

            break;
        }

    case DOMNode::ATTRIBUTE_NODE:
        {
            s = node->getNodeName();  // The attribute name
            addToCheckSum(s);
            s = node->getNodeValue();  // The attribute value
            if (s != 0)
                addToCheckSum(s);
            break;
        }

    case DOMNode::TEXT_NODE:
    case DOMNode::CDATA_SECTION_NODE:
        {
            s = node->getNodeValue();
            addToCheckSum(s);
            break;
        }

    case DOMNode::ENTITY_REFERENCE_NODE:
    case DOMNode::DOCUMENT_NODE:
        {
            // For entity references and the document, nothing is dirctly
            //  added to the checksum, but we do want to process the chidren nodes.
            //
            for (child=node->getFirstChild(); child!=0; child=child->getNextSibling())
                domCheckSum(child);
            break;
        }
    }
}
开发者ID:xin3liang,项目名称:platform_external_xerces-cpp,代码行数:59,代码来源:ThreadTest.cpp

示例12: nodesMatch

bool XmlParser::nodesMatch(DOMElement *mergeEl, DOMElement *patchEl) {

   DualString mergeTagName(mergeEl->getTagName());
   DualString patchTagName(patchEl->getTagName());
   if (verbose) {
      cerr << "Comparing Tag \'" << mergeTagName.asCString() << "\' to \'" << patchTagName.asCString();
   }
   if (!XMLString::equals(mergeTagName.asXMLString(), patchTagName.asXMLString())) {
      if (verbose) {
         cerr << "\' - false\n";
      }
      return false;
   }
   if (verbose) {
      cerr << "\' - equal\n";
   }
   DOMNamedNodeMap *patchAttributes = patchEl->getAttributes();

   unsigned attributeCount = patchAttributes->getLength();
   for (unsigned attrIndex = 0; attrIndex < attributeCount; attrIndex++) {
      DOMNode *attribute = patchAttributes->item(attrIndex);
      DualString attributeName(attribute->getNodeName());
      if (XMLString::equals(attributeName.asXMLString(), attr_merge_actions.asXMLString())) {
         if (verbose) {
            cerr << "Skipping attribute \'" << attributeName.asCString() << "\'\n";
         }
         continue;
      }
      if (verbose) {
         cerr << "Checking for attribute \'" << attributeName.asCString();
      }
      if (!mergeEl->hasAttribute(attributeName.asXMLString())) {
         if (verbose) {
            cerr << "\' - Not present\n";
         }
         return false;
      }
      if (verbose) {
         cerr << "\' - Present";
      }
      DualString patchAttributeValue(attribute->getNodeValue());
      DualString mergeAttributeValue(mergeEl->getAttribute(attributeName.asXMLString()));
      if (!XMLString::equals(patchAttributeValue.asXMLString(), mergeAttributeValue.asXMLString())) {
         if (verbose) {
            cerr << "\' - Not equal\n";
         }
         return false;
      }
      if (verbose) {
         cerr << "\' - Equal (" << patchAttributeValue.asCString() << ")\n";
      }
   }
   return true;
}
开发者ID:CoffeeHacker,项目名称:usbdm-eclipse-makefiles-build,代码行数:54,代码来源:xmlParser.cpp

示例13: parserDataSource

bool DataSource::parserDataSource(XSchema* pschema,xercesc::DOMElement* element)
{
	this->parentschema=pschema;

	if(element)
	{
		    DOMNamedNodeMap *attributes;
			DOMNodeList *children =element->getChildNodes();
			DOMNode *tmpnode;
			std::string tmpstr=XMLString::transcode(element->getNodeName());
			if(tmpstr!="DataSource")
			{
				return false;
			}

			attributes=element->getAttributes();

			if(attributes)
			{
				for(int j=0;j<attributes->getLength();j++)
				{
					tmpnode=attributes->item(j);
					tmpstr=XMLString::transcode(tmpnode->getNodeName());
					if(tmpstr == "type")
					{
						this->type_ = (DataSource::CUBETYPE) atoi(XMLString::transcode(tmpnode->getNodeValue()));
						
					}
					else if(tmpstr=="url")
					{
						this->_URL=XMLString::transcode(tmpnode->getNodeValue());
					}
					else if(tmpstr=="passWord")
					{
						this->_psword=XMLString::transcode(tmpnode->getNodeValue());
					}
					else if(tmpstr=="userName")
					{
						this->_UserName =XMLString::transcode(tmpnode->getNodeValue());
					}
				}			
			}
			else
			{
				return false;
			}			 
	}
	else
	{
		
		return false;
	}
	return true;
}
开发者ID:mydw,项目名称:mydw,代码行数:54,代码来源:DataSource.cpp

示例14: verifyUserTimestampElement

void AcsAlarmTestCase::verifyUserTimestampElement(DOMDocument * doc)
{
	// Verify the user-timestamp element
	DOMNodeList * userTimestampNodes = doc->getElementsByTagName(USER_TIMESTAMP_TAG_NAME);
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; no user-properties element found",
		(NULL != userTimestampNodes && userTimestampNodes->getLength() == 1));

	// verify that there are 2 attributes
	DOMNamedNodeMap * attributesMap = userTimestampNodes->item(0)->getAttributes();
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; user-timestamp contain attributes",
		(NULL!= attributesMap && attributesMap->getLength() == 0));
}
开发者ID:ACS-Community,项目名称:ACS,代码行数:12,代码来源:testXML.cpp

示例15: lookupNamespacePrefix

const XMLCh* DOMNodeImpl::lookupNamespacePrefix(const XMLCh* const namespaceURI, bool useDefault, DOMElement *el) const {
    DOMNode *thisNode = castToNode(this);

    const XMLCh* ns = thisNode->getNamespaceURI();
    // REVISIT: if no prefix is available is it null or empty string, or
    //          could be both?
    const XMLCh* prefix = thisNode->getPrefix();

    if (ns != 0 && XMLString::equals(ns,namespaceURI)) {
        if (useDefault || prefix != 0) {
            const XMLCh* foundNamespace =  el->lookupNamespaceURI(prefix);
            if (foundNamespace != 0 && XMLString::equals(foundNamespace, namespaceURI)) {
                return prefix;
            }
        }
    }
    if (thisNode->hasAttributes()) {
        DOMNamedNodeMap *nodeMap = thisNode->getAttributes();

        if(nodeMap != 0) {
            int length = nodeMap->getLength();

            for (int i = 0;i < length;i++) {
                DOMNode *attr = nodeMap->item(i);
                const XMLCh* attrPrefix = attr->getPrefix();
                const XMLCh* value = attr->getNodeValue();

                ns = attr->getNamespaceURI();

                if (ns != 0 && XMLString::equals(ns, XMLUni::fgXMLNSURIName)) {
                    // DOM Level 2 nodes
                    if ((useDefault && XMLString::equals(attr->getNodeName(), XMLUni::fgXMLNSString)) ||
                        (attrPrefix != 0 && XMLString::equals(attrPrefix, XMLUni::fgXMLNSString)) &&
                        XMLString::equals(value, namespaceURI)) {
                        const XMLCh* localname= attr->getLocalName();
                        const XMLCh* foundNamespace = el->lookupNamespaceURI(localname);
                        if (foundNamespace != 0 && XMLString::equals(foundNamespace, namespaceURI)) {
                            return localname;
                        }
                    }
                }
            }
        }
    }
    DOMNode *ancestor = getElementAncestor(thisNode);
    if (ancestor != 0) {
        return castToNodeImpl(ancestor)->lookupNamespacePrefix(namespaceURI, useDefault, el);
    }
    return 0;
}
开发者ID:jjiezheng,项目名称:pap_full,代码行数:50,代码来源:DOMNodeImpl.cpp


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