本文整理汇总了C++中DOMNode类的典型用法代码示例。如果您正苦于以下问题:C++ DOMNode类的具体用法?C++ DOMNode怎么用?C++ DOMNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DOMNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: throw
void
CADReader::connectevent (DOMElement* element)
throw(CADReadException)
{
std::string element_name;
EventConnectionData event_connection;
DOMNode* child = element->getFirstChild();
while (child != 0)
{
if (child->getNodeType() == DOMNode::ELEMENT_NODE)
{
element_name = XMLString::transcode(child->getNodeName());
//
// consumesport
//
if (element_name == "consumesport")
{
event_connection.consumer = consumesport((DOMElement*)(child));
}
//
// emitsport
//
else if (element_name == "emitsport")
{
event_connection.kind = EMITTER;
event_connection.emitter = emitsport((DOMElement*)(child));
}
//
// publishesport
//
else if (element_name == "publishesport")
{
event_connection.kind = PUBLISHER;
event_connection.emitter = publishesport((DOMElement*)(child));
}
}
// get next child
child = child->getNextSibling();
}
// add new event_connection
data_->event_connections_.push_back(event_connection);
}
示例2: createCompositeRule
void *NclPresentationControlParser::parseCompositeRule(
DOMElement *parentElement, void *objGrandParent) {
wclog << "parseCompositeRule" << endl;
void *parentObject;
DOMNodeList *elementNodeList;
DOMElement *element;
DOMNode *node;
string elementTagName;
void *elementObject;
parentObject = createCompositeRule(parentElement, objGrandParent);
if (parentObject == NULL) {
return NULL;
}
elementNodeList = parentElement->getChildNodes();
for (int i = 0; i < (int)elementNodeList->getLength(); i++) {
node = elementNodeList->item(i);
if (node->getNodeType() == DOMNode::ELEMENT_NODE) {
element = (DOMElement*)node;
elementTagName = XMLString::transcode(element->getTagName());
wclog << ">>" << elementTagName.c_str() << ": ";
wclog << XMLString::transcode(element->getAttribute(XMLString::transcode("id"))) << endl;
if (XMLString::compareIString(elementTagName.c_str(),
"rule") == 0) {
elementObject = parseRule(element, parentObject);
if (elementObject != NULL) {
addRuleToCompositeRule(parentObject, elementObject);
}
} else if(XMLString::compareIString(elementTagName.c_str(),
"compositeRule")==0) {
elementObject = parseCompositeRule(element, parentObject);
if (elementObject != NULL) {
addCompositeRuleToCompositeRule(
parentObject, elementObject);
}
}
}
}
return parentObject;
}
示例3: xiu
XERCES_CPP_NAMESPACE_BEGIN
DOMDocument *
XIncludeDOMDocumentProcessor::doXIncludeDOMProcess(const DOMDocument * const source, XMLErrorReporter *errorHandler, XMLEntityHandler* entityResolver /*=NULL*/){
XIncludeUtils xiu(errorHandler);
DOMImplementation* impl = source->getImplementation();
DOMDocument *xincludedDocument = impl->createDocument();
try
{
/* set up the declaration etc of the output document to match the source */
xincludedDocument->setDocumentURI( source->getDocumentURI());
xincludedDocument->setXmlStandalone( source->getXmlStandalone());
xincludedDocument->setXmlVersion( source->getXmlVersion());
/* copy entire source document into the xincluded document. Xincluded document can
then be modified in place */
DOMNode *child = source->getFirstChild();
for (; child != NULL; child = child->getNextSibling()){
if (child->getNodeType() == DOMNode::DOCUMENT_TYPE_NODE){
/* I am simply ignoring these at the moment */
continue;
}
DOMNode *newNode = xincludedDocument->importNode(child, true);
xincludedDocument->appendChild(newNode);
}
DOMNode *docNode = xincludedDocument->getDocumentElement();
/* parse and include the document node */
xiu.parseDOMNodeDoingXInclude(docNode, xincludedDocument, entityResolver);
xincludedDocument->normalizeDocument();
}
catch(const XMLErrs::Codes)
{
xincludedDocument->release();
return NULL;
}
catch(...)
{
xincludedDocument->release();
throw;
}
return xincludedDocument;
}
示例4: vddprintf
void DeltaApplyEngine::ApplyDeltaElement(DOMNode* incDeltaElement) {
vddprintf(("Apply delta element\n"));
deltaElement = incDeltaElement;
/* ---- Do All DELETE Operations ( including 'from' part of move ) ---- */
vddprintf(("Apply Delete operations\n"));
DOMNode* firstOp = deltaElement->getFirstChild() ;
vddprintf((" first sort delete operations...\n"));
SortDeleteOperationsEngine deleteOps(xiddoc, firstOp);
vddprintf((" then apply all of them 1 by 1...\n"));
while(!deleteOps.isListEmpty()) {
DOMNode* op=deleteOps.getNextDeleteOperation();
ApplyOperation(op);
}
vddprintf(("Ok, there are no more delete operations.\n"));
/* ---- Do All INSERT Operations ( including 'to' part of move ) ---- */
firstOp = deltaElement->getFirstChild() ;
SortInsertOperationsEngine insertOps(xiddoc, firstOp);
while(!insertOps.isListEmpty()) {
DOMNode* op=insertOps.getNextInsertOperation();
ApplyOperation(op);
}
/* ---- Do all UPDATE & ATTRIBUTE Operations ---- */
DOMNode* child = deltaElement->getFirstChild() ;
XMLCh iStr[100];
XMLString::transcode("i", iStr, 99);
XMLCh dStr[100];
XMLString::transcode("d", dStr, 99);
while (child != NULL) {
if ( (!XMLString::equals(child->getLocalName(),iStr))
&&(!XMLString::equals(child->getLocalName(), dStr)) ) ApplyOperation(child);
child = child->getNextSibling() ;
}
/* ---- Small consistency checks ---- */
if (moveDocument->getDocumentElement()->hasChildNodes()) THROW_AWAY(("temporary document used to move node is not empty!"));
vddprintf(("xiddoc=%s\n",xiddoc->getXidMap().String().c_str() ));
}
示例5: read
Metadata::Metadata(DOMDocument *doc)
{
DOMElement *metadataRootElem = doc->getDocumentElement();
if(metadataRootElem == NULL){
return;
}
XMLCh *keyValStr = XMLString::transcode("keyval");
DOMNodeList *keyValElems = metadataRootElem->getElementsByTagName(keyValStr);
const XMLSize_t nodeCount = keyValElems->getLength();
//cout << "Metadata::constructor: Found " << nodeCount << " keyval elements" << endl;
for(XMLSize_t i = 0; i < nodeCount; i++){
DOMNode* currentNode = keyValElems->item(i) ;
if(currentNode == NULL){
continue;
}
if( xercesc::DOMNode::ELEMENT_NODE != currentNode->getNodeType() ){
// not an element node -> not of interest here
continue ;
}
DOMElement* metadataElem = dynamic_cast< xercesc::DOMElement* >(currentNode);
string key;
read(metadataElem, "key", key);
vector<string> values;
readMany(metadataElem, "val", values);
/*cout << "Processing DOMElement (key, values): (" << key << ", ";
for(int j=0; j < values.size(); j++){
cout << values[j] << ", ";
}
cout << ")" << endl;*/
elementMap[key] = values;
}
}
示例6: CPPUNIT_ASSERT_MESSAGE
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);
}
}
示例7: extractDeviceInstance
static DeviceInstance extractDeviceInstance(DOMDocument * domDocument, DOMTreeWalker * domTreeWalker) {
DeviceInstance deviceInstance;
map<string, ParameterGroup> parameterGroupMap;
DOMNode * node = domTreeWalker->getCurrentNode();
DOMNamedNodeMap * nodeMap = node->getAttributes();
DOMNode * nameAttribute = nodeMap->getNamedItem(XMLString::transcode("name"));
if (nameAttribute) {
deviceInstance.setName(XMLString::transcode(nameAttribute->getNodeValue()));
}
DOMNode * typenameAttribute = nodeMap->getNamedItem(XMLString::transcode("typename"));
if (typenameAttribute) {
deviceInstance.setDeviceTypeName(XMLString::transcode(typenameAttribute->getNodeValue()));
}
while (node) {
if (XMLString::compareString(XMLString::transcode(node->getNodeName()), "ParameterGroup") == 0) {
DOMNamedNodeMap * nodeMap = node->getAttributes();
string name;
DOMNode * nameAttribute = nodeMap->getNamedItem(XMLString::transcode("name"));
if (nameAttribute) {
name = XMLString::transcode(nameAttribute->getNodeValue());
}
XMLNodeFilter * nodeFilter = new XMLNodeFilter();
DOMTreeWalker * d = domDocument->createTreeWalker(node, DOMNodeFilter::SHOW_ALL, nodeFilter, true);
ParameterGroup pg = extractParameterGroup(domDocument, d);
pg.setName(name);
parameterGroupMap[name] = pg;
d->release();
delete nodeFilter;
}
node = domTreeWalker->nextNode();
}
ParameterGroup parameterGroup;
parameterGroup.setName("root");
parameterGroup.setParameterGroupMap(parameterGroupMap);
deviceInstance.setParameterGroup(parameterGroup);
return deviceInstance;
}
示例8: THROW_EXCEPTION
//=============================================================================
// METHOD: SPELLxmlConfigReaderXC::findElementsByName
//=============================================================================
SPELLxmlNodeList SPELLxmlConfigReaderXC::findElementsByName( std::string tagName )
{
SPELLxmlNodeList result;
if (m_document == NULL)
{
THROW_EXCEPTION("Cannot find elements", "No document available", SPELL_ERROR_CONFIG);
}
DEBUG("[CFGR] Get elements by name: " + tagName);
// Get the tag translation
XMLCh* tag = XMLString::transcode(tagName.c_str());
// Get the top-level element
DOMElement* elementRoot = m_document->getDocumentElement();
if( !elementRoot )
{
THROW_EXCEPTION("Cannot get root element", "Empty document", SPELL_ERROR_CONFIG);
}
DOMNodeList* children = elementRoot->getChildNodes();
const XMLSize_t nodeCount = children->getLength();
// For all nodes, children of "root" in the XML tree.
for (XMLSize_t xx = 0; xx < nodeCount; ++xx)
{
DOMNode* currentNode = children->item(xx);
if (currentNode->getNodeType() && // true is not NULL
currentNode->getNodeType() == DOMNode::ELEMENT_NODE) // is element
{
// Found node which is an Element. Re-cast node as element
DOMElement* currentElement = dynamic_cast<xercesc::DOMElement*> (currentNode);
if (XMLString::equals(currentElement->getTagName(), tag))
{
result.push_back( convertToNode( currentElement ) );
}
}
}
XMLString::release(&tag);
DEBUG("[CFGR] Found " + ISTR(result.size()) + " elements");
return result;
}
示例9: extractConnectorVector
static vector<Connector> extractConnectorVector(DOMDocument * domDocument, DOMTreeWalker * domTreeWalker) {
vector<Connector> connectorVector;
DOMNode * node = domTreeWalker->getCurrentNode();
while (node) {
if (XMLString::compareString(XMLString::transcode(node->getNodeName()), "Connector") == 0) {
XMLNodeFilter * nodeFilter = new XMLNodeFilter();
DOMTreeWalker * d = domDocument->createTreeWalker(node, DOMNodeFilter::SHOW_ALL, nodeFilter, true);
Connector connector = extractConnector(domDocument, d);
connectorVector.push_back(connector);
d->release();
delete nodeFilter;
}
node = domTreeWalker->nextNode();
}
return connectorVector;
}
示例10: extractTUIObjectTypeMap
static map<string, TUIObjectType> extractTUIObjectTypeMap(DOMDocument * domDocument, DOMTreeWalker * domTreeWalker) {
map<string, TUIObjectType> tuiObjectTypeMap;
DOMNode * node = domTreeWalker->getCurrentNode();
while (node) {
if (XMLString::compareString(XMLString::transcode(node->getNodeName()), "TUIObjectType") == 0) {
XMLNodeFilter * nodeFilter = new XMLNodeFilter();
DOMTreeWalker * d = domDocument->createTreeWalker(node, DOMNodeFilter::SHOW_ALL, nodeFilter, true);
TUIObjectType tuiObjectType = extractTUIObjectType(domDocument, d);
tuiObjectTypeMap[tuiObjectType.getName()] = tuiObjectType;
d->release();
delete nodeFilter;
}
node = domTreeWalker->nextNode();
}
return tuiObjectTypeMap;
}
示例11: throw
void
CSDReader::valuetypefactory (DOMElement* element)
throw(CSDReadException)
{
std::string element_name;
ValuetypeData data;
data.repid = Qedo::transcode(element->getAttribute(X("repid")));
DOMNode* child = element->getFirstChild();
while (child != 0)
{
if (child->getNodeType() == DOMNode::ELEMENT_NODE)
{
element_name = Qedo::transcode(child->getNodeName());
//
// codebase
//
if (element_name == "codebase")
{
// todo
}
//
// fileinarchive
//
if (element_name == "fileinarchive")
{
data.location = fileinarchive((DOMElement*)child);
}
//
// link
//
if (element_name == "link")
{
data.location = link((DOMElement*)child);
}
}
// get next child
child = child->getNextSibling();
}
DEBUG_OUT2( "CSDReader: <valuetypefactory> ", data.repid );
data_->valuetypes.push_back(data);
}
示例12: addChild
XmlNode addChild(const char *name) {
XMLCh *tempStr = NULL;
tempStr = XMLString::transcode(name);
DOMElement *element = doc->createElement(tempStr);
DOMNode *cnode = node->appendChild(element);
XMLString::release(&tempStr);
return XmlNode(cnode,doc);
}
示例13: CPPUNIT_ASSERT_MESSAGE
void AcsAlarmTestCase::verifyDescriptorElement(DOMDocument * doc)
{
// Verify the descriptor element
DOMNodeList * descriptorNodes = doc->getElementsByTagName(DESCRIPTOR_TAG_NAME);
CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; no descriptor element found",
(NULL != descriptorNodes && descriptorNodes->getLength() == 1));
// check value of descriptor
DOMNode * descriptorElementNode = descriptorNodes->item(0);
DOMNode * descriptorTextNode = descriptorElementNode->getFirstChild();
CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; descriptor value is not present or null",
(NULL != descriptorTextNode));
const XMLCh * descriptorNodeValue = descriptorTextNode->getNodeValue();
CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; value of descriptor is not correct",
(NULL != descriptorNodeValue && XMLString::equals(descriptorNodeValue, DESCRIPTOR_VALUE_XMLCH)));
}
示例14: extractServerStartupConfig
static ServerStartupConfig extractServerStartupConfig(DOMDocument * domDocument, DOMTreeWalker * domTreeWalker) {
ServerStartupConfig serverStartupConfig;
DOMNode * node = domTreeWalker->getCurrentNode();
while (node) {
if (XMLString::compareString(XMLString::transcode(node->getNodeName()), "Network") == 0) {
DOMNamedNodeMap * nodeMap = node->getAttributes();
DOMNode * portAttribute = nodeMap->getNamedItem(XMLString::transcode("port"));
if (portAttribute) {
serverStartupConfig.setPortNr(XMLString::parseInt(portAttribute->getNodeValue()));
}
}
node = domTreeWalker->nextNode();
}
return serverStartupConfig;
}
示例15: removeType
void XercesUpdateFactory::completeDeletions(DynamicContext *context)
{
// e. Finally, for each node marked for deletion by one of the update primitives listed above, let $N be the node that is marked
// for deletion, and let $P be its parent node. The following actions are applied:
// i. The parent property of $N is set to empty.
// ii. If $N is an attribute node, the attributes property of $P is modified to remove $N.
// iii. If $N is a non-attribute node, the children property of $P is modified to remove $N.
// iv. If $N is an element, attribute, or text node, and $P is an element node, then upd:removeType($P) is invoked.
for(DOMNodeSet::iterator i = forDeletion_.begin(); i != forDeletion_.end(); ++i) {
DOMNode *domnode = *i;
if(domnode->getNodeType() == DOMNode::ATTRIBUTE_NODE) {
DOMAttr *attr = (DOMAttr*)domnode;
DOMElement *owner = attr->getOwnerElement();
if(owner != 0) {
owner->removeAttributeNode(attr);
removeType(owner);
}
}
else {
DOMNode *parent = domnode->getParentNode();
if(parent != 0) {
parent->removeChild(domnode);
if(domnode->getNodeType() == DOMNode::ELEMENT_NODE ||
domnode->getNodeType() == DOMNode::TEXT_NODE ||
domnode->getNodeType() == DOMNode::CDATA_SECTION_NODE) {
removeType(parent);
}
}
}
}
}