本文整理汇总了C++中DOMNamedNodeMap类的典型用法代码示例。如果您正苦于以下问题:C++ DOMNamedNodeMap类的具体用法?C++ DOMNamedNodeMap怎么用?C++ DOMNamedNodeMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DOMNamedNodeMap类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
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:
{
//.........这里部分代码省略.........
示例2: vddprintf
//.........这里部分代码省略.........
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"));
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() ;
XMLString::transcode("v", tempStr, 5);
const XMLCh* value = operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue() ;
Attribute_Insert( nodeXID, attr, value );
}
else if (XMLString::equals(operationNode->getLocalName(), auStr)) {
vddprintf((" a(ttribute) u(pdate)\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() ;
XMLString::transcode("nv", tempStr, 5);
const XMLCh* value = operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue() ;
Attribute_Update( nodeXID, attr, value );
}
else if (XMLString::equals(operationNode->getLocalName(), renameRootStr)) {
vddprintf((" renameRoot\n"));
DOMNode *root = xiddoc->getDocumentElement();
XID_t rootXID = xiddoc->getXidMap().getXIDbyNode(root);
XMLString::transcode("to", tempStr, 5);
const XMLCh* newrootName = operationNode->getAttributes()->getNamedItem(tempStr)->getNodeValue() ;
DOMElement* newroot = xiddoc->createElement(newrootName);
DOMNode* child = root->getFirstChild();
while(child!=NULL) {
root->removeChild(child);
newroot->appendChild(child);
child = root->getFirstChild();
}
DOMNamedNodeMap *attributes = root->getAttributes();
for(unsigned int i=0;i<attributes->getLength();i++) {
DOMNode *an = attributes->item(i);
newroot->setAttribute(an->getNodeName(), an->getNodeValue());
}
xiddoc->removeChild(root);
xiddoc->getXidMap().removeNode(root);
root->release();
xiddoc->appendChild(newroot);
xiddoc->getXidMap().registerNode(newroot, rootXID);
xiddoc->getXidMap().SetRootElement(newroot);
}
}
示例3: recurse
void XSECNameSpaceExpander::recurse(DOMElement *n) {
// Recursively go down the tree adding namespaces
DOMNode *p = n->getParentNode();
if (p->getNodeType() != DOMNode::ELEMENT_NODE)
return;
DOMNamedNodeMap *pmap = p->getAttributes();
XMLSize_t psize = pmap->getLength();
DOMNamedNodeMap *nmap = n->getAttributes();
safeBuffer pname, pURI, nURI;
DOMNode *finder;
XSECNameSpaceEntry * tmpEnt;
for (XMLSize_t i = 0; i < psize; i++) {
// Run through each parent node to find namespaces
pname << (*mp_formatter << pmap->item(i)->getNodeName());
// See if this is an xmlns node
if (pname.sbStrncmp("xmlns", 5) == 0) {
// It is - see if it already exists
finder = nmap->getNamedItem(pname.sbStrToXMLCh());
if (finder == 0) {
// Need to add
n->setAttributeNS(DSIGConstants::s_unicodeStrURIXMLNS,
pmap->item(i)->getNodeName(),
pmap->item(i)->getNodeValue());
// Add it to the list so it can be removed later
XSECnew(tmpEnt, XSECNameSpaceEntry);
tmpEnt->m_name.sbStrcpyIn(pname);
tmpEnt->mp_node = n;
tmpEnt->mp_att = nmap->getNamedItem(pname.sbStrToXMLCh());
m_lst.push_back(tmpEnt);
}
}
}
// Do the children
DOMNode *c;
c = n->getFirstChild();
while (c != NULL) {
if (c->getNodeType() == DOMNode::ELEMENT_NODE)
recurse((DOMElement *) c);
c = c->getNextSibling();
}
}
示例4: walkDocument
void TXFMXPathFilter::walkDocument(DOMNode * n) {
// Non-recursive version
DOMNode * current = n;
DOMNode * next;
DOMNode * attParent = NULL; /* Assign NULL to remove spurious Forte warning */
bool done = false;
bool treeUp = false;
DOMNamedNodeMap * atts = n->getAttributes();
int attsSize = -1;
int currentAtt = -1;
lstsVectorType::iterator lstsIter;
while (done == false && current != NULL) {
if (treeUp == true) {
if (current == n) {
// We are complete.
done = true;
}
else {
// Remove this node from the ancestor lists
for (lstsIter = m_lsts.begin(); lstsIter != m_lsts.end(); ++lstsIter) {
if ((*lstsIter)->ancestorInScope == current) {
(*lstsIter)->ancestorInScope = NULL;
}
}
// Check for another sibling
next = current->getNextSibling();
if (next == NULL) {
current = current->getParentNode();
treeUp = true;
}
else {
current = next;
treeUp = false;
}
}
} /* treeUp == true */
else {
// Check if the current node is in the result set. The walk the children
// First check if this node is in any lists, and if so,
// set the appropriate ancestor nodes (if necessary)
for (lstsIter = m_lsts.begin(); lstsIter != m_lsts.end(); ++lstsIter) {
if ((*lstsIter)->ancestorInScope == NULL &&
(*lstsIter)->lst->hasNode(current)) {
(*lstsIter)->ancestorInScope = current;
}
//
}
// Now that the ancestor setup is done, check to see if this node is
// in scope.
if (checkNodeInScope(current) &&
checkNodeInInput(current, (atts != NULL ? attParent : NULL))) {
m_xpathFilterMap.addNode(current);
}
// Now find the next node!
if (atts != NULL) {
// Working on an attribute list
currentAtt++;
if (currentAtt == attsSize) {
// Attribute list complete
atts = NULL;
current = attParent;
next = current->getFirstChild();
if (next == NULL)
treeUp = true;
//.........这里部分代码省略.........
示例5: EppMarkHolder
/* 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;
}
示例6: strtok
void *IndexedLineSet::read(DOMNode *node) {
#ifdef DEBUG1
cout << "Reading IndexedLineSet" << endl;
#endif
unsigned int i; // variable to counter
DOMNamedNodeMap *attributes; // variable to hold the node attributes
DOMNodeList *children; // variable to hold the node children
char *ctemp; // temporary variable
#ifndef XERCES // actualy is the xerces parser
char *ptrptr;
#endif
char* message;
attributes = node->getAttributes();
for (i = 0; i < attributes->getLength(); i++) {
if (!strcmp(XMLString::transcode(attributes->item(i)->getNodeName()) , "DEF")) {
strcpy(this->DEF,XMLString::transcode (attributes->item(i)->getNodeValue()));
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())));
} else
if (!strcmp(XMLString::transcode(attributes->item(i)->getNodeName()),"colorPerVertex")) {
if (!strcasecmp(XMLString::transcode(attributes->item(i)->getNodeValue()),"TRUE")) {
*this->colorPerVertex=true;
} else {
*this->colorPerVertex=false;
}
} else
if ( !strcmp(XMLString::transcode (attributes->item(i)->getNodeName()) , "coordIndex")) {
message = XMLString::transcode(attributes->item(i)->getNodeValue());
ctemp = strtok(message,", \n");
while (ctemp != NULL) {
coordIndex[f++] = atoi(ctemp);
ctemp = strtok(NULL,", \n");
if(this->f>=Minimum_MFVec3f) { // corigir
cerr << "Error IndexedLineSet bigger than buffer" << endl;
return(NULL);;
}
}
if(coordIndex[f-1]!=-1) {
coordIndex[f++]=-1;
}
} else
if ( !strcmp(XMLString::transcode (attributes->item(i)->getNodeName()) , "colorIndex")) {
#ifdef XERCES // actualy is the xerces parser
XMLStringTokenizer *tok = new XMLStringTokenizer( attributes->item(i)->getNodeValue() , XMLString::transcode(", \t\n\r\f") );
while(tok->hasMoreTokens()) {
x3d::x3DValues->MFInt32[this->counterColor++] = atoi(XMLString::transcode(tok->nextToken()));
if(x3d::x3DValues->MFInt32[this->counterColor] < -1) {
cout << "Warning value of CoordIndex outside the range" << endl;
}
if(this->counterColor>=Minimum_MFInt32) {
cerr << "Error coordIndex bigger than buffer" << endl;
return(NULL);;
}
}
delete tok;
#else
if(XMLString::stringLen(attributes->item(i)->getNodeValue()) >= Size_X3D_Message) {
cout << " Message exced the maximun size " << endl;
}
if(!XMLString::transcode(attributes->item(i)->getNodeValue(),x3d::message,Size_X3D_Message)) {
cout << " Message exced the maximun size " << endl;
}
ctemp = strtok_r(x3d::message,", \n",&ptrptr);
while (ctemp != NULL) {
x3d::x3DValues->MFInt32[this->counterColor++] = atoi(ctemp);
if(x3d::x3DValues->MFInt32[this->counterColor] < -1) {
cout << "Warning value of ColorIndex outside the range" << endl;
}
ctemp = strtok_r(NULL,", \n",&ptrptr);
if(this->counterColor>=Minimum_MFInt32) {
cerr << "Error colorIndex bigger than buffer" << endl;
return(NULL);;
}
}
#endif
if(x3d::x3DValues->MFInt32[this->counterColor-1]!=-1) {
x3d::x3DValues->MFInt32[this->counterColor++]=-1;
}
this->colorIndex = new int[this->counterColor];
//this->set_colorIndex = this->colorIndex; // just a copy
//.........这里部分代码省略.........
示例7: XMLStringTokenizer
void *Color::read(DOMNode *node) {
unsigned int i; // variable to counter
DOMNamedNodeMap *attributes; // variable to hold the node attributes
#ifndef XERCES
char *ctemp; // temporary variable
char *ptrptr;
#endif
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())));
} else
if ( !strcmp(XMLString::transcode(attributes->item(i)->getNodeName()), "color")) {
#ifdef XERCES // actualy is the xerces parser
XMLStringTokenizer *tok = new XMLStringTokenizer( attributes->item(i)->getNodeValue() , XMLString::transcode(", \t\n\r\f") );
while(tok->hasMoreTokens()) {
x3d::x3DValues->MFColor[this->numberOfElements++] = atof(XMLString::transcode(tok->nextToken()));
#ifdef DEGUB
cout << "Coordinate [ " << this->numberOfElements-1 << " :" << x3d::x3DValues->MFVec3f[this->numberOfElements-1] << endl;
#endif
if(this->numberOfElements>=Minimum_MFVec3f) {
cerr << "Error Coordinates bigger than buffer" << endl;
return(NULL);
}
}
delete tok;
#else
if(XMLString::stringLen(attributes->item(i)->getNodeValue()) >= Size_X3D_Message) {
cout << " Message exced the maximun size " << endl;
}
if(!XMLString::transcode(attributes->item(i)->getNodeValue(),x3d::message,Size_X3D_Message)) {
cout << " Message exced the maximun size " << endl;
}
ctemp = strtok_r(x3d::message,", \n",&ptrptr);
while (ctemp != NULL) {
x3d::x3DValues->MFColor[this->numberOfElements++] = atof(ctemp);
ctemp = strtok_r(NULL,", \n",&ptrptr);
#ifdef DEGUB
cout << "Coordinate [ " << f-1 << " :" << x3d::x3DValues->MFColor[f-1] << endl;
#endif
if(this->numberOfElements>=Minimum_MFColor) {
cerr << "Error Colors bigger than buffer" << endl;
return(NULL);;
}
}
#endif
}
}
this->value->aloc(numberOfElements);
unsigned int g; // counter
for(g=0;g<numberOfElements;g++){
value->data[g]=x3d::x3DValues->MFColor[g];
}
return(NULL);
}
示例8: 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(),
//.........这里部分代码省略.........
示例9: 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;
//.........这里部分代码省略.........
示例10: if
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;
}
}
}
示例11: FDPItem
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);
}
示例12: 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
//.........这里部分代码省略.........
示例13: if
bool FDPLoader::parseHeader(DOMNode* pHeader)
{
DOMNodeIterator* iterator = m_pDoc->createNodeIterator(pHeader,
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() )
{
// there are "file", "model", "fapu", "translation" and "rotation" elements in this chunk
if (XercesString(current->getNodeName()) == "file")
{
// sample: <file version="0.2" />
DOMNamedNodeMap* attr = current->getAttributes();
if(!attr) // sth wrong
return false;
DOMNode* versionAttr = attr->getNamedItem(XercesString("version"));
if(XercesString(m_version.c_str()) != versionAttr->getNodeValue())
// versions not matching, flee!!
return false;
}
else if(XercesString(current->getNodeName()) == "fapu")
{
// sample: <fapu ES0="69.9977" IRISD0="16.0424" ENS0="51.8036" MNS0="30.1538" MW0="50.6392" />
DOMNamedNodeMap* attrList = current->getAttributes();
if(!attrList) // sth wrong
return false;
/////////////// ES0
DOMNode* attr = attrList->getNamedItem(XercesString("ES0"));
if(attr)
m_pFDP->setES0(toFloat(attr->getNodeValue()));
/////////////// IRISD0
attr = attrList->getNamedItem(XercesString("IRISD0"));
if(attr)
m_pFDP->setIRISD0(toFloat(attr->getNodeValue()));
/////////////// ENS0
attr = attrList->getNamedItem(XercesString("ENS0"));
if(attr)
m_pFDP->setENS0(toFloat(attr->getNodeValue()));
/////////////// MNS0
attr = attrList->getNamedItem(XercesString("MNS0"));
if(attr)
m_pFDP->setMNS0(toFloat(attr->getNodeValue()));
/////////////// MW0
attr = attrList->getNamedItem(XercesString("MW0"));
if(attr)
m_pFDP->setMW0(toFloat(attr->getNodeValue()));
// debug << "fapu item" << std::endl;
}
else if(XercesString(current->getNodeName()) == "translation")
{
// sample: <translation x="0" y="-1" z="-659" />
DOMNamedNodeMap* attrList = current->getAttributes();
if(!attrList) // sth wrong
return false;
float x = 0, y = 0, z = 0;
/////////////// x translation
DOMNode* attr = attrList->getNamedItem(XercesString("x"));
if(attr)
x = toFloat(attr->getNodeValue());
/////////////// y translation
attr = attrList->getNamedItem(XercesString("y"));
if(attr)
y = toFloat(attr->getNodeValue());
/////////////// z translation
attr = attrList->getNamedItem(XercesString("z"));
if(attr)
z = toFloat(attr->getNodeValue());
m_pFDP->setGlobalTranslation(x, y, z);
// debug << "translation item " << x << " " << y << " " << z << std::endl;
}
else if(XercesString(current->getNodeName()) == "rotation")
{
// sample: <rotation axis_x="-0.998192" axis_y="0.0596591" axis_z="0.00728935" axis_angle="0.444541" />
DOMNamedNodeMap* attrList = current->getAttributes();
if(!attrList) // sth wrong
return false;
float x = 0, y = 0, z = 0, a = 0;
/////////////// x rotation
DOMNode* attr = attrList->getNamedItem(XercesString("axis_x"));
if(attr)
x = toFloat(attr->getNodeValue());
/////////////// y rotation
attr = attrList->getNamedItem(XercesString("axis_y"));
if(attr)
y = toFloat(attr->getNodeValue());
/////////////// z rotation
attr = attrList->getNamedItem(XercesString("axis_z"));
if(attr)
//.........这里部分代码省略.........