本文整理汇总了C++中DOMNode::getAttributes方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMNode::getAttributes方法的具体用法?C++ DOMNode::getAttributes怎么用?C++ DOMNode::getAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMNode
的用法示例。
在下文中一共展示了DOMNode::getAttributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandlerBase
map<string, DatasetSpecification> Specifications::readDatasetIndex(string str){
map<string, DatasetSpecification> result;
XERCES_CPP_NAMESPACE_USE
XMLPlatformUtils::Initialize();
XercesDOMParser parser;
parser.setValidationScheme(XercesDOMParser::Val_Always);
HandlerBase errHandler;// = (ErrorHandler*) new HandlerBase();
parser.setErrorHandler(&errHandler);
parser.parse(str.c_str());
DOMDocument * doc = parser.getDocument();
DOMElement* elementRoot = doc->getDocumentElement();
DOMNodeList *entries =
elementRoot->getElementsByTagName(XMLString::transcode("dataset"));
cout << "Databases in index:\n";
for(size_t i = 0; i < entries->getLength(); ++i){
DOMNode *current = entries->item(i);
DatasetSpecification dss;
dss.name = XMLString::transcode(current->getAttributes()->
getNamedItem(XMLString::transcode("name"))->
getNodeValue());
dss.root = XMLString::transcode(current->getAttributes()->
getNamedItem(XMLString::transcode("root"))->
getNodeValue());
cout << " name: " << dss.name << " root: " << dss.root << endl;
DOMNodeList *categories = current->getChildNodes();
for(size_t j = 0; j < categories->getLength(); ++j)
if((string) XMLString::transcode(categories->item(j)->getNodeName()) ==
"category")
dss.categories.push_back(XMLString::transcode(categories->item(j)->getTextContent()));
result[dss.name] = dss;
}
return result;
}
示例2: ParseGesture
bool CConfigParser::ParseGesture(DOMNode* node, TActionByNameMap actions, CDeviceContext* device)
{
TGestureList gestures;
wstring actionName = node->getAttributes()->getNamedItem(L"action")->getNodeValue();
unsigned long length = node->getChildNodes()->getLength();
for(unsigned long i = 0; i < length; i++)
{
DOMNode* gestNode = node->getChildNodes()->item(i);
wstring nodeType = gestNode->getNodeName();
if(nodeType.compare(L"#text") == 0)
continue;
if(nodeType.compare(L"motion") == 0)
{
wstring position = gestNode->getAttributes()->getNamedItem(L"position")->getNodeValue();
wstring axe = gestNode->getAttributes()->getNamedItem(L"axe")->getNodeValue();
EGesturePosition pos;
if(position.compare(L"positive") == 0)
pos = EGesturePosition::POSITIVE;
if(position.compare(L"negative") == 0)
pos = EGesturePosition::NEGATIVE;
if(position.compare(L"center") == 0)
pos = EGesturePosition::CENTER;
gestures.push_back(new CMotion(pos, _wtoi(axe.c_str())));
}
if(nodeType.compare(L"wait") == 0)
gestures.push_back(new CTimeFrame(_wtoi(gestNode->getAttributes()->getNamedItem(L"length")->getNodeValue())));
}
device->_gestureProcessor.addMacro(gestures, actions[actionName]);
return true;
}
示例3: ParseContexts
bool CConfigParser::ParseContexts(DOMNodeList* contextNodes, ADeviceListener& configClass)
{
ASSERT(contextNodes->getLength() == 1);
DOMNode* contextNode = contextNodes->item(0);
DOMNodeList* contexts = contextNode->getChildNodes();
for(unsigned long idx = 0; idx < contexts->getLength(); idx++)
{
DOMNode* currentContext = contexts->item(idx);
wstring contextNodeName = currentContext->getNodeName();
if(contextNodeName.compare(L"#text") == 0)
continue;
wstring contextName = currentContext->getAttributes()->getNamedItem(L"name")->getNodeValue();
CContext* contextToAdd = new CContext();
unsigned long attrLen = currentContext->getAttributes()->getLength();
for(unsigned long attr = 0; attr < attrLen; attr++)
{
DOMNode* deviceContextAttr = currentContext->getAttributes()->item(attr);
if(wcscmp(deviceContextAttr->getNodeName(), L"deviceContext") == 0)
{
wstring deviceContextName = deviceContextAttr->getNodeValue();
CDeviceContext* deviceContext = configClass.GetDeviceContexts()[deviceContextName];
IDeviceCapture* device = configClass.GetDevices()[deviceContext->GetDeviceName()];
contextToAdd->AddDeviceContext(device, deviceContext);
}
}
configClass.AddContext(contextName, contextToAdd);
}
return true;
}
示例4: ParseHIDDeviceCommands
bool CConfigParser::ParseHIDDeviceCommands(DOMNodeList* commandNodeList, CWin32SpaceNavigatorHIDCapture* device)
{
if(commandNodeList == NULL)
return true;
for(unsigned long idx = 0; idx < commandNodeList->getLength(); idx++)
{
DOMNode* currentCommand = commandNodeList->item(idx);
wstring commandNodeName = currentCommand->getNodeName();
if(commandNodeName.compare(L"command") != 0)
continue;
wstring commandName = currentCommand->getAttributes()->getNamedItem(L"name")->getNodeValue();
wstring commandReport = currentCommand->getAttributes()->getNamedItem(L"report")->getNodeValue();
wstring commandValue = currentCommand->getAttributes()->getNamedItem(L"value")->getNodeValue();
unsigned int report = NULL;
unsigned int value = NULL;
swscanf(commandReport.c_str(), L"0x%04X", &report);
swscanf(commandValue.c_str(), L"0x%04X", &value);
device->AddCommand(commandName, report, value);
}
return true;
}
示例5: ParseDeviceContexts
bool CConfigParser::ParseDeviceContexts(DOMNodeList* deviceContextNodes, ADeviceListener& configClass)
{
ASSERT(deviceContextNodes->getLength() == 1);
DOMNode* deviceContextNode = deviceContextNodes->item(0);
DOMNodeList* deviceContexts = deviceContextNode->getChildNodes();
for(unsigned long idx = 0; idx < deviceContexts->getLength(); idx++)
{
DOMNode* currentDeviceContext = deviceContexts->item(idx);
wstring deviceContextNodeName = currentDeviceContext->getNodeName();
if(deviceContextNodeName.compare(L"#text") == 0)
continue;
if(deviceContextNodeName.compare(L"#comment") == 0)
continue;
wstring deviceContextName = currentDeviceContext->getAttributes()->getNamedItem(L"name")->getNodeValue();
wstring deviceName = currentDeviceContext->getAttributes()->getNamedItem(L"device")->getNodeValue();
bool gestures = false;
if(currentDeviceContext->getAttributes()->getNamedItem(L"gestures") != NULL)
gestures = true;
// Create the device context to add
CDeviceContext* deviceContextToAdd = NULL;
if(configClass.GetDevices()[deviceName]->GetType().compare("mouse") == 0)
deviceContextToAdd = new CMouseDeviceContext(gestures, deviceName);
else
deviceContextToAdd = new CDeviceContext(gestures, deviceName);
// Get the device contexts axis and buttons added
if(currentDeviceContext->hasChildNodes())
{
unsigned char axeIdx = 0;
DOMNodeList* children = currentDeviceContext->getChildNodes();
unsigned long childCount = children->getLength();
for(unsigned long idx = 0; idx < childCount; idx++)
{
DOMNode* childNode = children->item(idx);
wstring nodeName = childNode->getNodeName();
if(nodeName.compare(L"axe") == 0)
{
ParseAxe(childNode, configClass.GetActions(), deviceContextToAdd, axeIdx);
axeIdx++;
}
if(nodeName.compare(L"buttons") == 0)
ParseButtons(childNode, configClass.GetActions(), deviceContextToAdd);
if(nodeName.compare(L"gesture") == 0)
ParseGesture(childNode, configClass.GetActions(), deviceContextToAdd);
}
}
configClass.AddDeviceContext(deviceContextName, deviceContextToAdd);
TRACE("Device Context <%S> is 0x%X\r\n", deviceContextName.c_str(), deviceContextToAdd);
}
return true;
}
示例6: extractMSPInstance
static MSPInstance extractMSPInstance(DOMDocument * domDocument, DOMTreeWalker * domTreeWalker) {
MSPInstance mspInstance;
map<string, ParameterGroup> parameterGroupMap;
DOMNode * node = domTreeWalker->getCurrentNode();
DOMNamedNodeMap * nodeMap = node->getAttributes();
DOMNode * nameAttribute = nodeMap->getNamedItem(XMLString::transcode("name"));
if (nameAttribute) {
mspInstance.setName(XMLString::transcode(nameAttribute->getNodeValue()));
}
DOMNode * typeNameAttribute = nodeMap->getNamedItem(XMLString::transcode("typename"));
if (typeNameAttribute) {
//TFDEBUG(XMLString::transcode(typeNameAttribute->getNodeValue()));
mspInstance.setTypeName(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;
} else if (XMLString::compareString(XMLString::transcode(node->getNodeName()), "Description") == 0) {
XMLCh * textContent = XMLString::replicate(node->getTextContent());
XMLString::trim(textContent);
mspInstance.setDescription(XMLString::transcode(textContent));
XMLString::release(&textContent);
}
node = domTreeWalker->nextNode();
}
ParameterGroup parameterGroup;
parameterGroup.setName("root");
parameterGroup.setParameterGroupMap(parameterGroupMap);
mspInstance.setParameterGroup(parameterGroup);
return mspInstance;
}
示例7: extractParameterGroup
static ParameterGroup extractParameterGroup(DOMDocument * domDocument, DOMTreeWalker * domTreeWalker) {
map<string, string> parameterMap;
map<string, ParameterGroup> parameterGroupMap;
DOMNode * node = domTreeWalker->nextNode();
while (node) {
if (XMLString::compareString(XMLString::transcode(node->getNodeName()), "Parameter") == 0) {
DOMNamedNodeMap * nodeMap = node->getAttributes();
string name;
DOMNode * nameAttribute = nodeMap->getNamedItem(XMLString::transcode("name"));
if (nameAttribute) {
name = XMLString::transcode(nameAttribute->getNodeValue());
}
string value;
DOMNode * valueAttribute = nodeMap->getNamedItem(XMLString::transcode("value"));
if (valueAttribute) {
value = XMLString::transcode(valueAttribute->getNodeValue());
}
parameterMap[name] = value;
//TFINFO("Parameter: " << name << " -> " << value);
} else 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.setParameterMap(parameterMap);
parameterGroup.setParameterGroupMap(parameterGroupMap);
return parameterGroup;
}
示例8: ParseDevices
bool CConfigParser::ParseDevices(DOMNodeList* deviceNodeList, ADeviceListener& configClass)
{
ASSERT(deviceNodeList->getLength() >= 1);
DOMNode* deviceNode = deviceNodeList->item(0);
DOMNodeList* devices = deviceNode->getChildNodes();
for(unsigned long idx = 0; idx < devices->getLength(); idx++)
{
DOMNode* currentDevice = devices->item(idx);
wstring deviceNodeName = currentDevice->getNodeName();
if(deviceNodeName.compare(L"#text") == 0)
continue;
wstring deviceName = currentDevice->getAttributes()->getNamedItem(L"name")->getNodeValue();
//wstring deviceType = currentDevice->getAttributes()->getNamedItem(L"type")->getNodeValue();
wstring deviceType = deviceNodeName;
if(deviceType.compare(L"mouse") == 0)
{
configClass.AddDevice(deviceName, new CMouseProc());
}
else
{
CWin32SpaceNavigatorHIDCapture* deviceToAdd = new CWin32SpaceNavigatorHIDCapture();
if(currentDevice->hasChildNodes())
{
if(!ParseHIDDeviceCommands(currentDevice->getChildNodes(), deviceToAdd))
return false;
}
configClass.AddDevice(deviceName, deviceToAdd);
}
}
return true;
}
示例9: extractTUIObjectInstance
static TUIObjectInstance extractTUIObjectInstance(DOMDocument * domDocument, DOMTreeWalker * domTreeWalker) {
TUIObjectInstance tuiObjectInstance;
DOMNode * node = domTreeWalker->getCurrentNode();
DOMNamedNodeMap * nodeMap = node->getAttributes();
DOMNode * nameAttribute = nodeMap->getNamedItem(XMLString::transcode("name"));
if (nameAttribute) {
tuiObjectInstance.setName(XMLString::transcode(nameAttribute->getNodeValue()));
}
DOMNode * tuiTypeNameAttribute = nodeMap->getNamedItem(XMLString::transcode("typename"));
if (tuiTypeNameAttribute) {
tuiObjectInstance.setTypeName(XMLString::transcode(tuiTypeNameAttribute->getNodeValue()));
}
while (node) {
if (XMLString::compareString(XMLString::transcode(node->getNodeName()), "Description") == 0) {
XMLCh * textContent = XMLString::replicate(node->getTextContent());
XMLString::trim(textContent);
tuiObjectInstance.setDescription(XMLString::transcode(textContent));
XMLString::release(&textContent);
}
node = domTreeWalker->nextNode();
}
return tuiObjectInstance;
}
示例10: extractTUIObjectType
static TUIObjectType extractTUIObjectType(DOMDocument * domDocument, DOMTreeWalker * domTreeWalker) {
TUIObjectType tuiObjectType;
DOMNode * node = domTreeWalker->getCurrentNode();
DOMNamedNodeMap * nodeMap = node->getAttributes();
DOMNode * nameAttribute = nodeMap->getNamedItem(XMLString::transcode("name"));
if (nameAttribute) {
tuiObjectType.setName(XMLString::transcode(nameAttribute->getNodeValue()));
}
while (node) {
if (XMLString::compareString(XMLString::transcode(node->getNodeName()), "PortTypeSequence") == 0) {
XMLNodeFilter * nodeFilter = new XMLNodeFilter();
DOMTreeWalker * d = domDocument->createTreeWalker(node, DOMNodeFilter::SHOW_ALL, nodeFilter, true);
tuiObjectType.setPortMap(extractPortMap(domDocument, d));
d->release();
delete nodeFilter;
} else if (XMLString::compareString(XMLString::transcode(node->getNodeName()), "Description") == 0) {
XMLCh * textContent = XMLString::replicate(node->getTextContent());
XMLString::trim(textContent);
tuiObjectType.setDescription(XMLString::transcode(textContent));
XMLString::release(&textContent);
}
node = domTreeWalker->nextNode();
}
return tuiObjectType;
}
示例11: getAttributeValue
/**
* extract's the value of an attribute and returns it:
*
* <parentNode>
* <elementNode attribute="returnstring" />
* </parentNode>
*
* the first parentNode found in the document is used. thus, it is expected to be unique.
*
* @param parentNode
* @param elementNode
* @param attribute
* @return
*/
string InputHandler::getAttributeValue(const XMLCh* parentNode, const XMLCh* elementNode, const XMLCh* attribute)
{
crusde_debug("%s, line: %d, InputHandler::getAttributeValue(%s) ", __FILE__, __LINE__, XMLString::transcode(elementNode));
DOMElement *root = doc->getDocumentElement();
DOMNodeList *node_list = root->getElementsByTagName(parentNode);
/*if element does not exist, return emptry string*/
if(node_list->getLength() == 0)
return string();
DOMNode *child = node_list->item(0)->getFirstChild();
DOMNamedNodeMap *attributes = NULL;
while (child)
{
if( child->getNodeType() == DOMNode::ELEMENT_NODE)
{
attributes = child->getAttributes();
if( XMLString::compareIString(child->getNodeName(), elementNode) == 0 )
{
char *val = XMLString::transcode(attributes->getNamedItem(attribute)->getNodeValue());
string value(val);
XMLString::release(&val);
return value;
}
}
child = child->getNextSibling();
}
return string();
}
示例12: getDestinationURI
std::string DeltaApplyEngine::getDestinationURI(XID_DOMDocument *IncDeltaDoc) {
DOMNode* deltaElement = DeltaApplyEngine::getDeltaElement(IncDeltaDoc);
DOMNode* toItem = deltaElement->getAttributes()->getNamedItem(XMLString::transcode("to"));
if (toItem==NULL) THROW_AWAY(("attribute 'to' not found"));
return std::string(XyLatinStr(toItem->getNodeValue()));
}
示例13: msg
set<string>* EpiMCMCConfig::getParameterNames()
{
/** Returns a pointer to an STL set of parameter names.
Throws a ConfigException if duplicate names are found in the DOM **/
XMLCh* buff; // Character buffer. Used to delete objects mainly.
buff = XMLString::transcode("parameter");
DOMNodeList* parmList = doc->getElementsByTagName(buff);
XMLString::release(&buff);
set<string>* parmNames = new set<string>;
pair<set<string>::iterator,bool> isInserted;
for(size_t i = 0; i<parmList->getLength(); ++i) {
DOMNode* parm = parmList->item(i);
buff = XMLString::transcode("id");
DOMNode* idAttr = parm->getAttributes()->getNamedItem(buff);
XMLString::release(&buff);
char* id = XMLString::transcode(idAttr->getNodeValue()) ;
isInserted = parmNames->insert(id);
if(isInserted.second == false) {
string msg("Duplicate string inserted: ");
msg += id;
XMLString::release(&id);
throw ConfigException(msg.c_str());
}
XMLString::release(&id);
}
return parmNames;
}
示例14: 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;
}
示例15: 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);
}
}