本文整理汇总了C++中DOMNode::getNodeValue方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMNode::getNodeValue方法的具体用法?C++ DOMNode::getNodeValue怎么用?C++ DOMNode::getNodeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMNode
的用法示例。
在下文中一共展示了DOMNode::getNodeValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
memset(attList, 0, sizeof(attList));
for (XMLSize_t i = 0; i < attrCount; i++) {
DOMNode* attribute = eltAttrs->item(i);
const XMLCh* attName = attribute->getNodeName();
// skip namespace declarations
if (XMLString::equals(attName, XMLUni::fgXMLNSString)
|| XMLString::startsWith(attName, XMLUni::fgXMLNSColonString))
continue;
// Bypass attributes that start with xml
// add this to the list of "non-schema" attributes
if ((*attName == chLatin_X || *attName == chLatin_x)
&& (*(attName+1) == chLatin_M || *(attName+1) == chLatin_m)
&& (*(attName+2) == chLatin_L || *(attName+2) == chLatin_l)) {
if (nonXSAttList)
nonXSAttList->addElement(attribute);
continue;
}
// for attributes with namespace prefix
const XMLCh* attrURI = attribute->getNamespaceURI();
if (attrURI != 0 && *attrURI) {
// attributes with schema namespace are not allowed
// and not allowed on "documentation" and "appInfo"
if (XMLString::equals(attrURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA) ||
XMLString::equals(elemName, SchemaSymbols::fgELT_APPINFO) ||
XMLString::equals(elemName, SchemaSymbols::fgELT_DOCUMENTATION)) {
schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain,
isTopLevel?XMLErrs::AttributeDisallowedGlobal:XMLErrs::AttributeDisallowedLocal,
attName, elemName);
}
else if (nonXSAttList)
{
nonXSAttList->addElement(attribute);
}
continue;
}
int attNameId = A_Invalid;
attName = attribute->getLocalName();
bool bContinue=false; // workaround for Borland bug with 'continue' in 'catch'
try {
attNameId= fAttMap->get(attName, fMemoryManager);
}
catch(const OutOfMemoryException&)
{
throw;
}
catch(...) {
schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain,
isTopLevel?XMLErrs::AttributeDisallowedGlobal:XMLErrs::AttributeDisallowedLocal,
attName, elemName);
bContinue=true;
}
if(bContinue)
continue;
if (fgElemAttTable[elemContext][attNameId] & Att_Mask) {
attList[attNameId] = 1;
validate
(
elem
, attName
, attribute->getNodeValue()
, fgElemAttTable[elemContext][attNameId] & DV_Mask
, schema
);
}
else {
schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain,
isTopLevel?XMLErrs::AttributeDisallowedGlobal:XMLErrs::AttributeDisallowedLocal,
attName, elemName);
}
}
// ------------------------------------------------------------------
// Check for required attributes
// ------------------------------------------------------------------
for (unsigned int j=0; j < A_Count; j++) {
if ((fgElemAttTable[elemContext][j] & Att_Required) && attList[j] == 0) {
schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain,
isTopLevel?XMLErrs::AttributeRequiredGlobal:XMLErrs::AttributeRequiredLocal,
fAttNames[j], elemName);
}
}
}
示例2: initParamsFromDOM
void InputHandler::initParamsFromDOM(DOMNode *node, multimap<string, ParamWrapper*> registry)
{
assert(node);
char *tmp = XMLString::transcode(node->getNodeName());
crusde_debug("%s, line: %d, initParamsFromDOM for node: %s.", __FILE__, __LINE__, tmp);
XMLString::release(&tmp);
DOMNode *child = node->getFirstChild();
DOMNamedNodeMap *attributes = NULL;
DOMNode *attr = NULL;
multimap<string, ParamWrapper*>::iterator key_iter;
pair< multimap<string, ParamWrapper*>::iterator, multimap<string, ParamWrapper*>::iterator > key_range;
list<string> params_set;
int count_keys(-1);
unsigned int count_set(0);
int empty_param(0);
while (child)
{
if( child->getNodeType() == DOMNode::ELEMENT_NODE)
{
attributes = child->getAttributes();
attr = attributes->getNamedItem(ATTR_name.xmlStr());
char* name = XMLString::transcode(attr->getNodeValue());
if( XMLString::compareIString(child->getNodeName(), TAG_parameter.xmlStr()) == 0 )
{
//get number of keys that equal name
count_keys = static_cast<int>( registry.count(string(name)) );
//if there is anything in the registry ...
if( count_keys > 0 )
{
//equal_range gives two results: an iterator to the first and last element with key==name
key_range = registry.equal_range(string(name));
//all keys have values that are adresses of double variables in the repsective plugins
//each of those variables now gets a value assigned. the same value.
for ( key_iter=key_range.first; key_iter != key_range.second; ++key_iter)
{
//get the value from the DOM
StrXML value(attributes->getNamedItem(ATTR_value.xmlStr())->getNodeValue());
//write it into the variable that's strored at key_iter->second
if( (key_iter->second)->isString() )
{
(key_iter->second)->setValue( value.cppStr() );
}
else if( (key_iter->second)->isDouble() )
{
(key_iter->second)->setValue( static_cast<double>( atof(value.cStr()) ) );
}
++count_set;
}
//memorize the key that was set only once
params_set.push_back(key_range.first->first);
}
else //if not found there might be a spelling mistake either in input, or plugin, or both :)
{
StrXML paramName(attributes->getNamedItem(ATTR_name.xmlStr())->getNodeValue());
crusde_warning("Parameter %s (coming from the experiment definition) not registered! Misspelled in XML file or Plug-in definition?",paramName.cStr());
}
}
XMLString::release(&name);
}
child = child->getNextSibling();
}
//two cases are possible for leftover parameters:
// i) they are optional parameters - check registry for that
// ii) they are unitialized - oh well, we gotta stop there
if(count_set < registry.size())
{
multimap<string, ParamWrapper*>::iterator map_iter = registry.begin();
list<string>::iterator found_iter;
string out_string("Error: Parameters that remain uninitialized: \n");
while (map_iter != registry.end())
{
if(!map_iter->second->isOptional())
{
found_iter = params_set.begin();
//as long as we're not at the end and could not find the parameter in the list of set
//parameters, continue looking.
while( found_iter != params_set.end() && (*found_iter).compare(map_iter->first) != 0 )
{
++found_iter;
}
//if we're at the end, the parameter was not in out list ... tell the user.
if(found_iter==params_set.end() )
{
++empty_param;
out_string.append("\t");
out_string.append(map_iter->first);
out_string.append("\n");
//.........这里部分代码省略.........
示例3: removeBaseAttr
static void removeBaseAttr(DOMDocument * domDocument) {
XMLNodeFilter * nodeFilter = new XMLNodeFilter();
DOMTreeWalker * domTreeWalker = domDocument->createTreeWalker(domDocument, DOMNodeFilter::SHOW_ALL, nodeFilter, true);
DOMNode * node = domTreeWalker->getCurrentNode();
while (node) {
DOMNamedNodeMap * nodeMap = node->getAttributes();
if (nodeMap != 0) {
DOMNode * attr = nodeMap->getNamedItem(XMLString::transcode("xml:base"));
if (attr) {
DOMNode * node = nodeMap->removeNamedItem(XMLString::transcode("xml:base"));
TFINFO("[Server Config] filtered attribute: " << XMLString::transcode(node->getNodeName()) << "=" << XMLString::transcode(node->getNodeValue()));
node->release();
}
}
node = domTreeWalker->nextNode();
}
delete nodeFilter;
}
示例4: outputContent
xmlstream& operator<<(xmlstream& target, const DOMNode* toWrite)
{
// Get the name and value out for convenience
const XMLCh* nodeName = toWrite->getNodeName();
const XMLCh* nodeValue = toWrite->getNodeValue();
switch (toWrite->getNodeType())
{
case DOMNode::TEXT_NODE:
{
outputContent(target, nodeValue);
break;
}
case DOMNode::PROCESSING_INSTRUCTION_NODE :
{
target << XMLStrL("<?")
<< nodeName
<< XMLStrL(' ')
<< nodeValue
<< XMLStrL("?>");
break;
}
case DOMNode::DOCUMENT_NODE :
{
//
// Bug here: we need to find a way to get the encoding name
// for the default code page on the system where the program
// is running, and plug that in for the encoding name.
//
XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* document=(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument*)toWrite;
target << XMLStrL("<?xml version=\"") << document->getVersion() << XMLStrL("\"");
const XMLCh* str = document->getEncoding();
if (str != 0)
target << XMLStrL(" encoding=\"") << str << XMLStrL("\"");
if(document->getStandalone())
target << XMLStrL(" standalone=\"yes\"");
target << XMLStrL("?>");
DOMNode* child = toWrite->getFirstChild();
while( child != 0)
{
target << child;
child = child->getNextSibling();
}
break;
}
case DOMNode::ELEMENT_NODE :
{
// Output the element start tag.
target << XMLStrL('<') << nodeName;
// Output any attributes on this element
DOMNamedNodeMap* attributes = toWrite->getAttributes();
int attrCount = attributes->getLength();
for (int i = 0; i < attrCount; i++)
{
DOMNode* attribute = attributes->item(i);
target << XMLStrL(' ') << attribute->getNodeName()
<< XMLStrL(" = \"");
// Note that "<" must be escaped in attribute values.
outputContent(target, attribute->getNodeValue());
target << XMLStrL('"');
}
//
// Test for the presence of children, which includes both
// text content and nested elements.
//
DOMNode* child = toWrite->getFirstChild();
if (child != 0)
{
// There are children. Close start-tag, and output children.
target << XMLStrL(">");
while( child != 0)
{
target << child;
child = child->getNextSibling();
}
// Done with children. Output the end tag.
target << XMLStrL("</") << nodeName << XMLStrL(">");
}
else
{
//
// There were no children. Output the short form close of
// the element start tag, making it an empty-element tag.
//
target << XMLStrL("/>");
}
break;
}
case DOMNode::ENTITY_REFERENCE_NODE:
{
//.........这里部分代码省略.........
示例5: loadEntity
void FDPLoader::loadEntity(DOMNode* pSource)
{
DOMNamedNodeMap* attrList = pSource->getAttributes();
std::string alias, category;
DOMNode* attr = attrList->getNamedItem(XercesString("alias"));
if(attr)
{
char* aliasPtr = XMLString::transcode(attr->getNodeValue());
alias.assign(aliasPtr);
XMLString::release(&aliasPtr);
}
attr = attrList->getNamedItem(XercesString("category"));
if(attr)
{
char* catPtr = XMLString::transcode(attr->getNodeValue());
category.assign(catPtr);
XMLString::release(&catPtr);
}
DOMNodeIterator* iterator = m_pDoc->createNodeIterator(pSource,
DOMNodeFilter::SHOW_ELEMENT | DOMNodeFilter::SHOW_ATTRIBUTE, NULL, true);
// use the tree walker to print out the text nodes.
for ( DOMNode* current = iterator->nextNode(); current != 0; current = iterator->nextNode() )
{
if(XercesString(current->getNodeName()) == "mesh")
{
char *fileTmp, *formatTmp, *pathTmp;
XEngine::MeshInfo info;
attrList = current->getAttributes();
attr = attrList->getNamedItem(XercesString("file"));
if(attr)
{
fileTmp = XMLString::transcode(attr->getNodeValue());
info.file.assign(fileTmp);
XMLString::release(&fileTmp);
}
attr = attrList->getNamedItem(XercesString("format"));
if(attr)
{
formatTmp = XMLString::transcode(attr->getNodeValue());
info.format.assign(formatTmp);
XMLString::release(&formatTmp);
}
attr = attrList->getNamedItem(XercesString("path"));
if(attr)
{
pathTmp = XMLString::transcode(attr->getNodeValue());
info.path.assign(pathTmp);
XMLString::release(&pathTmp);
}
else
info.path.assign("");
info.keyframe_alias = alias;
info.keyframe_category = category;
if(alias == "Rest")
m_faceEntityMeshInfo.push_back(info);
// push the Rest state into the morph target dictionary as well
m_morphTargetsMeshInfos[alias].push_back(info);
}
else if(XercesString(current->getNodeName()) == "bind")
{
XEngine::MeshInfo info;
std::string submesh, item;
attrList = current->getAttributes();
attr = attrList->getNamedItem(XercesString("submesh"));
if(attr)
{
char* submeshTmp = XMLString::transcode(attr->getNodeValue());
submesh.assign(submeshTmp);
XMLString::release(&submeshTmp);
}
attr = attrList->getNamedItem(XercesString("item"));
if(attr)
{
char* itemTmp = XMLString::transcode(attr->getNodeValue());
item.assign(itemTmp);
XMLString::release(&itemTmp);
}
if(item == "LeftEye" || item == "RightEye") // eye pivots
{
Vector3 eye(0, 0, 0);
//std::string x, y, z;
attr = attrList->getNamedItem(XercesString("pivotX"));
if(attr)
eye.x = toFloat(attr->getNodeValue());
attr = attrList->getNamedItem(XercesString("pivotY"));
if(attr)
eye.y = toFloat(attr->getNodeValue());
attr = attrList->getNamedItem(XercesString("pivotZ"));
if(attr)
eye.z = toFloat(attr->getNodeValue());
if(item == "LeftEye")
m_pFDP->setLeftEyePivot(eye);
else
//.........这里部分代码省略.........
示例6: ApplyOperation
void DeltaApplyEngine::ApplyOperation(DOMNode *operationNode) {
vddprintf(("ApplyOperation\n"));
XMLCh dStr[2];
XMLCh iStr[2];
XMLCh uStr[2];
XMLCh adStr[3];
XMLCh aiStr[3];
XMLCh auStr[3];
XMLCh renameRootStr[11];
XMLString::transcode("d", dStr, 1);
XMLString::transcode("i", iStr, 1);
XMLString::transcode("u", uStr, 1);
XMLString::transcode("ad", adStr, 2);
XMLString::transcode("ai", aiStr, 2);
XMLString::transcode("au", auStr, 2);
XMLString::transcode("renameRoot", renameRootStr, 10);
XMLCh tempStr[6];
if (XMLString::equals(operationNode->getLocalName(), dStr)) {
vddprintf((" d(elete)\n"));
bool move = false ;
XMLString::transcode("move", tempStr, 5);
DOMNode* moveAttr = operationNode->getAttributes()->getNamedItem(tempStr) ;
XMLString::transcode("yes", tempStr, 5);
if ((moveAttr!=NULL) && (XMLString::equals(moveAttr->getNodeValue(),tempStr))) {
move = true;
}
XMLString::transcode("xm", tempStr, 5);
char *xidmapStr = XMLString::transcode(operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue());
if (move) {
XidMap_Parser parse(xidmapStr) ;
XID_t myXid = parse.getRootXID();
Subtree_MoveFrom( myXid );
}
else {
Subtree_Delete(xidmapStr) ;
}
XMLString::release(&xidmapStr);
}
else if (XMLString::equals(operationNode->getLocalName(),iStr)) {
vddprintf((" i(nsert)\n"));
bool move = false ;
XMLString::transcode("move", tempStr, 5);
DOMNode* moveAttr = operationNode->getAttributes()->getNamedItem(tempStr) ;
XMLString::transcode("yes", tempStr, 5);
if ( (moveAttr!=NULL) && (XMLString::equals( moveAttr->getNodeValue(), tempStr ))) {
move = true;
}
XMLString::transcode("pos", tempStr, 5);
DOMNode *n = operationNode->getAttributes()->getNamedItem(tempStr);
int position = XyInt(n->getNodeValue());
XMLString::transcode("par", tempStr, 5);
n = operationNode->getAttributes()->getNamedItem(tempStr);
XID_t parentXID = (XID_t)(int)XyInt(n->getNodeValue());
XMLString::transcode("xm", tempStr, 5);
char *xidmapStr = XMLString::transcode(operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue());
if (move) {
XidMap_Parser parse(xidmapStr) ;
XID_t myXid = parse.getRootXID();
Subtree_MoveTo( myXid, parentXID, position );
}
else {
DOMNode* insertRoot ;
// get data to insert
if (operationNode->hasChildNodes()) insertRoot = operationNode->getFirstChild() ;
else THROW_AWAY(("insert operator element contains no data"));
Subtree_Insert( insertRoot, parentXID, position, xidmapStr ) ;
}
XMLString::release(&xidmapStr);
}
else if (XMLString::equals(operationNode->getLocalName(), uStr)) {
vddprintf((" u(pdate)\n"));
XMLString::transcode("oldxm", tempStr, 5);
char *xidmapStr = XMLString::transcode(operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue());
XidMap_Parser parse(xidmapStr) ;
XID_t nodeXID = parse.getRootXID();
TextNode_Update( nodeXID, operationNode);
XMLString::release(&xidmapStr);
}
else if (XMLString::equals(operationNode->getLocalName(), adStr)) {
vddprintf((" a(ttribute) d(elete)\n"));
XMLString::transcode("xid", tempStr, 5);
XID_t nodeXID = (XID_t)(int)XyInt(operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue());
XMLString::transcode("a", tempStr, 5);
const XMLCh* attr = operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue() ;
Attribute_Delete( nodeXID, attr );
}
else if (XMLString::equals(operationNode->getLocalName(), aiStr)) {
vddprintf((" a(ttribute) i(nsert)\n"));
//.........这里部分代码省略.........
示例7: fromXML
/* NOTE: need to keep _type field in consideration as attribute type/entitlement depends on it.*/
EppMarkHolder* EppMarkHolder::fromXML( const DOMNode& root, const char* ns )
{
/*
this->_name = _src._name;
this->_org = _src._org;
this->_addr = _src._addr;
this->_voice = _src._voice;
this->_fax = _src._fax;
this->_email = _src._email;
this->_addParam = _src._addParam;
this->_type = _src._type;
*/
EppMarkHolder *_ret = new EppMarkHolder(EPPMARK_HOLDER, ns);
//_ret->setNameSpace(ns);
int nsLen = strlen(ns);
if( null == _ret )
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.substringData(0, nsLen + 1).equals((_ret->getNameSpace() + ":").c_str()) )
{
name = name.substringData(nsLen + 1, name.length() - ( nsLen + 1 ));
if( name.equals("name") )
{
_ret->_name = EppUtil::getText(*node);
}
else if ( name.equals("org") )
{
_ret->_org = EppUtil::getText(*node);
}
else if ( name.equals("addr") )
{
EppMarkAddress* mAddr = (EppMarkAddress*)EppMarkAddress::fromXML( *node, ns );
_ret->_addr = *mAddr;
delete mAddr;
}
else if ( name.equals("voice") )
{
EppE164 *_v = EppE164::fromXML(*node);
if( NULL != _v )
{
_ret->_voice = *_v;
delete _v;
}
}
else if ( name.equals("fax") )
{
EppE164 *_f = EppE164::fromXML(*node);
if( NULL != _f )
{
_ret->_fax = *_f;
delete _f;
}
}
else if ( name.equals("email") )
{
_ret->_email = EppUtil::getText(*node);
}
}
}
for( unsigned int i = 0; i < attrs->getLength();i++ )
{
DOMNode* attr = attrs->item(i);
DOMString _v = attr->getNodeValue();
if( XS(attr->getNodeName()).equals("entitlement") )
{
_ret->_type = EPPMARK_HOLDER;
if( _v.length() > 0 )
{
_ret->_addParam = _v;
}
break;
}
else if ( XS(attr->getNodeName()).equals("type") )
{
_ret->_type = EPPMARK_CONTACT;
if( _v.length() > 0 )
{
_ret->_addParam = _v;
}
break;
}
}
return _ret;
}
示例8: refreshItemLists
void CTibiaItem::refreshItemLists()
{
if (!criticalSectionInitialized)
{
InitializeCriticalSection(&ItemsInitCriticalSection);
criticalSectionInitialized = true;
}
EnterCriticalSection(&ItemsInitCriticalSection);
if (itemListsFresh)
{
LeaveCriticalSection(&ItemsInitCriticalSection);
return;
}
itemListsFresh = 1;
if (!xmlInitialised)
{
XMLPlatformUtils::Initialize();
xmlInitialised = 1;
}
XercesDOMParser *parser = new XercesDOMParser();
try
{
int listNr, itemNr, rootNr;
//reset all lists
constCodeList.RemoveAll();
foodList.RemoveAll();
lootList.RemoveAll();
itemList.RemoveAll();
if (itemTree)
delete itemTree;
itemTree = new CTibiaTree(new CTibiaTreeBranchData("Root"));
char pathBuf[2048];
sprintf(pathBuf, "%s\\data\\tibiaauto-items.xml", CInstallPath::getInstallPath().c_str());
parser->parse(pathBuf);
DOMNode *doc = parser->getDocument();
for (rootNr = 0; rootNr < (int)doc->getChildNodes()->getLength(); rootNr++)
{
DOMNode *root = doc->getChildNodes()->item(rootNr);
if (wcscmp(root->getNodeName(), L"item-definitions"))
continue;
for (listNr = 0; listNr < (int)root->getChildNodes()->getLength(); listNr++)
{
DOMNode *listNode = root->getChildNodes()->item(listNr);
//ITEMS
if (!wcscmp(listNode->getNodeName(), L"items"))
//recursively add to itemTree from XML tree, works with older versions
parseItemsBranch(listNode, itemTree);
//FOOD
if (!wcscmp(listNode->getNodeName(), L"foods"))
{
for (itemNr = 0; itemNr < (int)listNode->getChildNodes()->getLength(); itemNr++)
{
int attrNr;
DOMNode *item = listNode->getChildNodes()->item(itemNr);
if (wcscmp(item->getNodeName(), L"item"))
continue;
int objectId = 0;
int eatTime = 0;
char *objectName = NULL;
for (attrNr = 0; attrNr < (int)item->getAttributes()->getLength(); attrNr++)
{
DOMNode *attrNode = item->getAttributes()->item(attrNr);
if (!wcscmp(attrNode->getNodeName(), L"name"))
objectName = CUtil::wc2c(attrNode->getNodeValue());
if (!wcscmp(attrNode->getNodeName(), L"id"))
{
char *idTmp = CUtil::wc2c(attrNode->getNodeValue());
sscanf(idTmp, "0x%x", &objectId);
if (objectId == 0)
sscanf(idTmp, "%d", &objectId);
free(idTmp);
}
if (!wcscmp(attrNode->getNodeName(), L"time"))
{
char *idTmp = CUtil::wc2c(attrNode->getNodeValue());
sscanf(idTmp, "%d", &eatTime);
free(idTmp);
}
}
if (!objectId || !objectName || !strlen(objectName))
{
if (objectName)
free(objectName);
continue;
}
foodList.Add(objectId, objectName, eatTime);
if (objectName)
free(objectName);
//delete item;//wis
}
//.........这里部分代码省略.........
示例9: indentStr
bool
XMLParserThread::xmlParseSMSFormatRequest( DOMNode* cur,
DOMNode* out,
DOMDocument* reply,
bool indent )
try {
bool ok = true;
int indentLevel = 1;
MC2String indentStr( indentLevel*3, ' ' );
indentStr.insert( 0, "\n" );
XStr XindentStr( indentStr.c_str() );
bool smsMessage = false;
bool routeMessage = false;
bool wayfinderRouteSMS = false;
bool wayfinderDestinationSMS = false;
bool wayfinderFavouriteSMS = false;
char* smsMessageText = NULL;
char* phoneModelName = NULL;
char* phoneManufacturerName = NULL;
uint32 routeID = 0;
uint32 routeCreateTime = 0;
StringTable::languageCode language = StringTable::ENGLISH;
char* signature = NULL;
char* originString = NULL;
char* originLocationString = NULL;
char* destinationString = NULL;
char* destinationLocationString = NULL;
CellularPhoneModel* model = NULL; // For routeMessage
bool wapLink = false; // For routeMessage
int32 wayfinderSMSVersion = MAX_INT32;
int32 wayfinderOriginLat = MAX_INT32;
int32 wayfinderOriginLon = MAX_INT32;
int32 wayfinderDestinationLat = MAX_INT32;
int32 wayfinderDestinationLon = MAX_INT32;
MC2String wayfinderOriginDescription;
MC2String wayfinderDestinationDescription;
MC2String errorCode = "-1";
MC2String errorMessage = "Failed to handle request.";
int32 wayfinderFavouriteLat;
int32 wayfinderFavouriteLon;
MC2String wayfinderFavouriteName;
MC2String wayfinderFavouriteShortName;
MC2String wayfinderFavouriteDescription;
MC2String wayfinderFavouriteCategory;
MC2String wayfinderFavouriteMapIconName;
// Create sms_format_reply element
DOMElement* sms_format_reply =
reply->createElement( X( "sms_format_reply" ) );
// Transaction ID
sms_format_reply->setAttribute(
X( "transaction_id" ), cur->getAttributes()->getNamedItem(
X( "transaction_id" ) )->getNodeValue() );
out->appendChild( sms_format_reply );
if ( indent ) {
// Newline
out->insertBefore( reply->createTextNode( XindentStr.XMLStr() ),
sms_format_reply );
}
// Look for Wayfinder sms version
DOMNamedNodeMap* attributes = cur->getAttributes();
DOMNode* attribute;
for ( uint32 i = 0 ; i < attributes->getLength() ; i++ ) {
attribute = attributes->item( i );
if ( XMLString::equals( attribute->getNodeName(),
"wayfinder_sms_version" ) ) {
MC2String tmpStr =
XMLUtility::transcodefrom( attribute->getNodeValue() );
wayfinderSMSVersion = atoi( tmpStr.c_str() );
}
}
XMLSMSCommon::InviteData inviteData; // for invite_sms
XMLSMSCommon::PlaceSMSData placeData; // for place_sms
for ( DOMNode* child = cur->getFirstChild();
child != NULL && ok;
child = child->getNextSibling() ) {
if ( child->getNodeType() != DOMNode::ELEMENT_NODE ) {
continue;
}
// See if the element is a known type
if ( XMLString::equals( child->getNodeName(), "smsmessage" ) ) {
smsMessageText = XMLUtility::getChildTextValue( child );
smsMessage = true;
} else if ( XMLString::equals( child->getNodeName(),
"phone_manufacturer" ) ) {
phoneManufacturerName =
XMLUtility::getChildTextValue( child );
} else if ( XMLString::equals( child->getNodeName(),
"phone_model" ) ) {
phoneModelName = XMLUtility::getChildTextValue( child );
} else if ( XMLString::equals( child->getNodeName(),
"route_sms_message" ) ) {
routeMessage =
xmlParseSendSMSRequestRouteSMSMessage( child, model, wapLink );
} else if ( XMLString::equals( child->getNodeName(),
//.........这里部分代码省略.........
示例10: switch
void
DomUtilsInternal::Dom2XMLString(
const DOMNode* toWrite,
XMLFormatter& fmt )
{
int i;
DOMNode child;
int attrCount;
DOMString id;
DOMNamedNodeMap attributes;
DOMDocumentType doctype;
// Get the name and value out for convenience
DOMString nodeName = toWrite.getNodeName();
DOMString nodeValue = toWrite.getNodeValue();
unsigned long lent = nodeValue.length();
switch (toWrite.getNodeType())
{
case DOMNode::ELEMENT_NODE:
// The name has to be representable without any escapes
fmt << XMLFormatter::NoEscapes << chOpenAngle << nodeName;
// Output the element start tag.
// Output any attributes on this element
attributes = ((DOMElement&)toWrite).getAttributes();
attrCount = attributes.getLength();
for (i = 0; i < attrCount; i++)
{
DOMNode attribute = attributes.item(i);
//
// Again the name has to be completely representable. But the
// attribute can have refs and requires the attribute style
// escaping.
//
fmt << XMLFormatter::NoEscapes
<< chSpace << attribute.getNodeName()
<< chEqual << chDoubleQuote
<< XMLFormatter::AttrEscapes
<< attribute.getNodeValue()
<< XMLFormatter::NoEscapes
<< chDoubleQuote;
}
//
// Test for the presence of children, which includes both
// text content and nested elements.
//
child = toWrite.getFirstChild();
if ( !child.isNull() )
{
// There are children. Close start-tag, and output children.
// No escapes are legal here
fmt << XMLFormatter::NoEscapes << chCloseAngle;
while( !child.isNull() )
{
DomUtilsInternal::Dom2XMLString( child, fmt );
child = child.getNextSibling();
}
//
// Done with children. Output the end tag.
//
fmt << XMLFormatter::NoEscapes << gEndElement
<< nodeName << chCloseAngle;
}
else
{
//
// There were no children. Output the short form close of
// the element start tag, making it an empty-element tag.
//
fmt << XMLFormatter::NoEscapes << chForwardSlash << chCloseAngle;
}
break;
case DOMNode::TEXT_NODE:
fmt.formatBuf( nodeValue.rawBuffer(), lent, XMLFormatter::CharEscapes );
break;
case DOMNode::CDATA_SECTION_NODE :
fmt << XMLFormatter::NoEscapes << gStartCDATA
<< nodeValue << gEndCDATA;
break;
case DOMNode::ENTITY_REFERENCE_NODE:
fmt << XMLFormatter::NoEscapes << chAmpersand
<< nodeName << chSemiColon;
break;
case DOMNode::PROCESSING_INSTRUCTION_NODE :
fmt << XMLFormatter::NoEscapes << gStartPI << nodeName;
if (lent > 0)
{
fmt << chSpace << nodeValue;
//.........这里部分代码省略.........
示例11: getParameters
void GeomAttributesBuilder::getParameters()
{
// First set default parameters.
// The parameters are dependent on the type of geom
// box: length, width, height (all doubles)
// ccylinder: radius, length (all doubles)
// sphere: radius (all doubles)
// plane: normal_x, normal_y, normal_z, d (all doubles)
// mesh: filname (std::string)
std::string type = attrib_->getValAsStr("type");
if (!type.compare("box")) {
attrib_->add("length", "1");
attrib_->add("width", "1");
attrib_->add("height", "1");
} else if (!type.compare("ccylinder")) {
attrib_->add("radius", "1");
attrib_->add("length", "3");
} else if (!type.compare("cylinder")) {
attrib_->add("radius", "1");
attrib_->add("length", "3");
} else if (!type.compare("sphere")) {
attrib_->add("radius", "1");
} else if (!type.compare("plane")) {
attrib_->add("normal_x", "0");
attrib_->add("normal_y", "0");
attrib_->add("normal_z", "1");
attrib_->add("d", "0");
} else if (!type.compare("mesh")) {
attrib_->add("filename", "_NODATA_");
} else {
return;
}
DOMNodeList* allChildNodes = node_->getChildNodes();
// Loop over all of the parameters
for (unsigned int c = 0; c < allChildNodes->getLength(); ++c) {
DOMNode* thisChildItem = allChildNodes->item(c);
if (thisChildItem->getNodeType() == DOMNode::ELEMENT_NODE) {
char* pChildTagName = XMLString::transcode(thisChildItem->getNodeName());
if ( strcmp(pChildTagName, "parameter") == 0 ) {
if ( thisChildItem->hasAttributes() )
{
DOMNamedNodeMap* theAttributes = thisChildItem->getAttributes();
int numAttributes = theAttributes->getLength();
if (numAttributes == 2) { // Parameters can only 1 Name/Value pair
DOMNode* nodeName = theAttributes->item(0);
DOMNode* nodeValue = theAttributes->item(1);
const XMLCh* xmlch_Name = nodeName->getNodeValue();
char* attrName = XMLString::transcode(xmlch_Name);
const XMLCh* xmlch_Value = nodeValue->getNodeValue();
char* attrValue = XMLString::transcode(xmlch_Value);
try {
attrib_->update(attrName, attrValue);
} catch (std::runtime_error &ex) {
std::cerr << ex.what() << std::endl
<< builderType_ << "::getParameters() - "
<< "In geom \"" << attrib_->getValAsStr("name")
<< "\", parameter \"" << attrName << "=" << attrValue
<< "\" is illegal for this geom type ("
<< attrib_->getValAsStr("type")
<< "). Ignoring it." << std::endl;
};
XMLString::release( &attrName );
XMLString::release( &attrValue );
}
}
}
delete [] pChildTagName;
}
}
}
示例12: loadFDPItem
void FDPLoader::loadFDPItem(DOMNode* pFDPItem)
{
DOMNamedNodeMap* attrList = pFDPItem->getAttributes();
FDPItem* pItem = 0;
// get the name (id)
DOMNode* attr = attrList->getNamedItem(XercesString("name"));
if(attr)
{
char* name = XMLString::transcode(attr->getNodeValue());
// create a new item (will be deleted in dtor of FDP class)
pItem = new FDPItem(name);
XMLString::release(&name);
}
else
return;
// get the control vertex index
attr = attrList->getNamedItem(XercesString("index"));
if(attr)
{
char* index = XMLString::transcode(attr->getNodeValue());
pItem->setControlPoint((unsigned short)atoi(index));
XMLString::release(&index);
}
// get the affecting mesh name
attr = attrList->getNamedItem(XercesString("affects"));
if(attr)
{
char* affects = XMLString::transcode(attr->getNodeValue());
pItem->setAffects(affects);
XMLString::release(&affects);
}
DOMNodeIterator* iterator = m_pDoc->createNodeIterator(pFDPItem,
DOMNodeFilter::SHOW_ELEMENT | DOMNodeFilter::SHOW_ATTRIBUTE, NULL, true);
// use the tree walker to print out the text nodes.
for ( DOMNode* current = iterator->nextNode(); current != 0; current = iterator->nextNode() )
{
if(XercesString(current->getNodeName()) == "indices")
{
DOMNodeList* children = current->getChildNodes();
// we should have only one child, text node, just a safety net here
if ( (children->getLength() == 1) && (children->item(0)->getNodeType() == DOMNode::TEXT_NODE) )//(XercesString(children->item(0)->getNodeName()) == "#text") )
{
char* pStr = XMLString::transcode(children->item(0)->getNodeValue());
std::string str(pStr);
processIndices(str, pItem);
XMLString::release(&pStr);
}
}
else if (XercesString(current->getNodeName()) == "influence") // can have multiple of those
{
// sample: <influence weight="0.25" fap="3" type="RaisedCosInfluenceWaveY" />
DOMNamedNodeMap* influenceAttr = current->getAttributes();
// get the weight
float w = toFloat(influenceAttr->getNamedItem(XercesString("weight"))->getNodeValue());
unsigned short fap = (unsigned short)toFloat(influenceAttr->getNamedItem(XercesString("fap"))->getNodeValue());
char* typeTmp = XMLString::transcode(influenceAttr->getNamedItem(XercesString("type"))->getNodeValue());
std::string type;
type.assign(typeTmp);
XMLString::release(&typeTmp);
IInfluenceCalculator* pInfluence = InfluenceCalculatorMaker::newInfluenceCalculator(type, w, fap);
if(pInfluence)
pItem->addInfluenceCalculator(pInfluence);
}
}
m_pFDP->insertItem(pItem);
}
示例13: readHash
unsigned int DSIGReference::readHash(XMLByte *toFill, unsigned int maxToFill) {
// Determine the hash value stored in the reference
// First set up for input
unsigned int size;
DOMNode *tmpElt;
//const XMLCh * stringHash;
TXFMBase * nextInput;
DOMDocument *d = mp_referenceNode->getOwnerDocument();
safeBuffer b64HashVal;
// Find the hash value
tmpElt = mp_referenceNode->getFirstChild();
while (tmpElt != 0 && !strEquals(getDSIGLocalName(tmpElt), "DigestValue"))
tmpElt = tmpElt->getNextSibling();
if (tmpElt == NULL)
// ERROR
return 0;
// Now read the DOMString of the hash
tmpElt = tmpElt->getFirstChild();
while (tmpElt != NULL && tmpElt->getNodeType() != DOMNode::TEXT_NODE)
tmpElt = tmpElt->getNextSibling();
if (tmpElt == NULL)
// Something wrong with the underlying XML if no text was found
throw XSECException(XSECException::NoHashFoundInDigestValue);
b64HashVal << (*mp_formatter << tmpElt->getNodeValue());
// Now have the value of the string - create a transform around it
XSECnew(nextInput, TXFMSB(d));
((TXFMSB *) nextInput)->setInput(b64HashVal);
// Create a transform chain (really as a janitor for the entire list)
TXFMChain * chain;
XSECnew(chain, TXFMChain(nextInput));
Janitor<TXFMChain> j_chain(chain);
// Now create the base64 transform
XSECnew(nextInput, TXFMBase64(d));
chain->appendTxfm(nextInput);
// Now get the value
size = chain->getLastTxfm()->readBytes(toFill, maxToFill);
// Clear any documentat modifications
chain->getLastTxfm()->deleteExpandedNameSpaces();
return size;
}
示例14: ParseActions
bool CConfigParser::ParseActions(DOMNodeList* actionNodeList, ADeviceListener& configClass)
{
USES_CONVERSION;
// Parse all the actions
if(actionNodeList != NULL && actionNodeList->getLength() > 0)
{
DOMNodeList* actionNodes = actionNodeList->item(0)->getChildNodes();
for(unsigned long i = 0; i < actionNodes->getLength(); i++)
{
DOMNode* actionNode = actionNodes->item(i);
wstring actionType = actionNode->getNodeName();
if(actionType.compare(L"#text") == 0)
continue;
XMLCh* xmlChNameTxt = L"name";
wstring actionName;
if(actionNode->hasAttributes())
{
DOMNode* nameAttribute = actionNode->getAttributes()->getNamedItem(xmlChNameTxt);
actionName = nameAttribute->getNodeValue();
}
if(actionType.compare(L"sendCopyDataWindowMessage") == 0 || actionType.compare(L"sendCommandWindowMessage") == 0)
{
wstring message = actionNode->getAttributes()->getNamedItem(L"message")->getNodeValue();
bool findByClass = FALSE;
wstring windowAttributeName = L"window";
if(actionNode->getAttributes()->getNamedItem(L"window") == NULL)
{
findByClass = TRUE;
windowAttributeName = L"windowClass";
}
wstring window = actionNode->getAttributes()->getNamedItem(windowAttributeName.c_str())->getNodeValue();
CSendWindowMessageAction* messageActionToAdd = NULL;
if(actionType.compare(L"sendCommandWindowMessage") == 0)
{
messageActionToAdd = new CSendWindowMessageAction(_wtol(message.c_str()), OLE2T(window.c_str()), findByClass);
}
if(actionType.compare(L"sendCopyDataWindowMessage") == 0)
{
messageActionToAdd = new CSendWindowMessageAction(OLE2T(message.c_str()), OLE2T(window.c_str()), findByClass);
}
if(messageActionToAdd != NULL)
configClass.AddAction(actionName, messageActionToAdd);
}
if(actionType.compare(L"execute") == 0)
{
char* executable = XMLString::transcode(
actionNode->getAttributes()->getNamedItem(L"executable")->getNodeValue());
char* commandline = XMLString::transcode(
actionNode->getAttributes()->getNamedItem(L"commandline")->getNodeValue());
configClass.AddAction(actionName, new CExecuteAction(executable, commandline));
XMLString::release(&executable);
XMLString::release(&commandline);
}
if(actionType.compare(L"keyPress") == 0)
{
TKeyList keys;
DOMNodeList* keyNodes = actionNode->getChildNodes();
unsigned long count = keyNodes->getLength();
for(unsigned long keyIdx=0; keyIdx < keyNodes->getLength(); keyIdx++)
{
DOMNode* keyNode = keyNodes->item(keyIdx);
if(wcscmp(keyNode->getNodeName(), L"#text") == 0)
continue;
const XMLCh* keyValue = keyNode->getFirstChild()->getNodeValue();
if(keyValue == NULL)
continue;
int test = VK_CONTROL;
keys.push_back(_wtoi(keyValue));
}
configClass.AddAction(actionName, new CKeyboardAction(keys));
}
if(actionType.compare(L"winampPlayPause") == 0)
{
configClass.AddAction(actionName, new CWinampPlayPause());
}
if(actionType.compare(L"winampMute") == 0)
{
configClass.AddAction(actionName, new CWinampMute());
}
// We make the assumption that the macros were put at the end of the
// config file, otherwise the actions they execute may not exist!
if(actionType.compare(L"macro") == 0)
{
wstring type = actionNode->getAttributes()->getNamedItem(L"type")->getNodeValue();
CMacroAction* actionToAdd = new CMacroAction(type.compare(L"all") == 0 ? true : false);
DOMNodeList* macroActions = actionNode->getChildNodes();
unsigned long count = macroActions->getLength();
for(unsigned long actionIdx=0; actionIdx < count; actionIdx++)
{
DOMNode* macroActionNode = macroActions->item(actionIdx);
if(wcscmp(macroActionNode->getNodeName(), L"#text") == 0)
continue;
wstring macroActionName = macroActionNode->getAttributes()->getNamedItem(L"name")->getNodeValue();
actionToAdd->AddAction(configClass.GetActions()[macroActionName]);
//.........这里部分代码省略.........
示例15: parseItemsBranch
void parseItemsBranch(DOMNode* listNode, CTibiaTree* parent)
{
for (int itemNr = 0; itemNr < (int)listNode->getChildNodes()->getLength(); itemNr++)
{
int attrNr;
DOMNode *item = listNode->getChildNodes()->item(itemNr);
if (item->getNodeType() != 1)
continue;
if (!wcscmp(item->getNodeName(), L"item"))
{
int objectId = 0;
int objectLoot = 0;
int type = 0;
char *objectName = NULL;
for (attrNr = 0; attrNr < (int)item->getAttributes()->getLength(); attrNr++)
{
DOMNode *attrNode = item->getAttributes()->item(attrNr);
if (!wcscmp(attrNode->getNodeName(), L"name"))
objectName = CUtil::wc2c(attrNode->getNodeValue());
if (!wcscmp(attrNode->getNodeName(), L"id"))
{
char *idTmp = CUtil::wc2c(attrNode->getNodeValue());
sscanf(idTmp, "0x%x", &objectId);
if (objectId == 0)
sscanf(idTmp, "%d", &objectId);
free(idTmp);
}
if (!wcscmp(attrNode->getNodeName(), L"looted"))
{
char *idTmp = CUtil::wc2c(attrNode->getNodeValue());
sscanf(idTmp, "%d", &objectLoot);
free(idTmp);
}
if (!wcscmp(attrNode->getNodeName(), L"type"))
{
char *idTmp = CUtil::wc2c(attrNode->getNodeValue());
sscanf(idTmp, "%d", &type);
free(idTmp);
}
}
if (!objectId || !objectName || !strlen(objectName))
{
if (objectName)
free(objectName);
continue;
}
parent->AddChild(new CTibiaTreeItemData(objectName, objectId, objectLoot != 0, type));
if (objectName)
free(objectName);
}
if (!wcscmp(item->getNodeName(), L"branch"))
{
char *branchName = NULL;
for (attrNr = 0; attrNr < (int)item->getAttributes()->getLength(); attrNr++)
{
DOMNode *attrNode = item->getAttributes()->item(attrNr);
if (!wcscmp(attrNode->getNodeName(), L"name"))
branchName = CUtil::wc2c(attrNode->getNodeValue());
}
if (!branchName || !strlen(branchName))
{
if (branchName)
free(branchName);
continue;
}
CTibiaTree* child = parent->AddChild(new CTibiaTreeBranchData(branchName));
parseItemsBranch(item, child);
if (branchName)
free(branchName);
}
}
}